From 6b8d567c70495667a28a0c229025cd8604376a01 Mon Sep 17 00:00:00 2001 From: l198881 <82917144+l198881@users.noreply.github.com> Date: Tue, 25 May 2021 19:12:39 -0300 Subject: [PATCH] fix (#1) Co-authored-by: Beaudinn Greve --- ecosystem.config.js | 12 ++++++++++++ start.js | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 ecosystem.config.js create mode 100644 start.js diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 000000000..2d95474f4 --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,12 @@ +module.exports = { + apps: [ + { + name: 'demo', + script: './start.js', + env: { + HOST: 'localhost', + PORT: 3000 + } + } + ], +} diff --git a/start.js b/start.js new file mode 100644 index 000000000..56186d860 --- /dev/null +++ b/start.js @@ -0,0 +1,27 @@ +// First, we need a js script to link in the ecosystem file, +// This is the script that will run our `npm start` command. + +const exec = require("child_process").exec; // Or es6 modules, you know, I'm not your supervisor. + +console.log( + `Starting app for production` // you may have different envs... +); + +// Here's the good part +// by default the command line tool will be cmd! Check the docs: +// https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback + +const build = exec("yarn run start", { stdio: "inherit", windowsHide: true }); + +build.stdout && build.stdout.on("data", console.log); +build.stderr && build.stderr.on("data", console.log); + +build.on("close", code => { + if (code !== 0) { + console.log(`Build process exited with code ${code}`); + } + + if (build.stdin) { + build.stdin.end(); + } +});