40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.default = run;
|
|
const child_process_1 = require("child_process");
|
|
const console_colors_1 = __importDefault(require("./console-colors"));
|
|
let redeployments = 0;
|
|
const KILL_SIGNAL = "SIGTERM";
|
|
const pTitle = "nodecid";
|
|
process.title = pTitle;
|
|
/**
|
|
* ## Preflight Function
|
|
* @param {string} command
|
|
* @returns {ChildProcess | null}
|
|
*/
|
|
function run(command) {
|
|
console.log("\n******************************");
|
|
console.log(`****** ${console_colors_1.default.FgGreen}Starting App ...${console_colors_1.default.Reset} ******`);
|
|
console.log("******************************\n");
|
|
const startCommandArray = command.split(" ").filter((str) => str.trim());
|
|
try {
|
|
const firstCommand = startCommandArray.shift();
|
|
if (!firstCommand) {
|
|
throw new Error("No Starting Command Found in command string!");
|
|
}
|
|
let childProcess = (0, child_process_1.spawn)(firstCommand, startCommandArray, {
|
|
stdio: "inherit",
|
|
killSignal: KILL_SIGNAL,
|
|
});
|
|
redeployments++;
|
|
return childProcess;
|
|
}
|
|
catch (error) {
|
|
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} running start command => ${error.message}`);
|
|
return null;
|
|
}
|
|
}
|