backend-manager 3.2.178 → 3.2.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,25 +2,34 @@ const powertools = require('node-powertools');
|
|
|
2
2
|
const yargs = require('yargs/yargs');
|
|
3
3
|
const { hideBin } = require('yargs/helpers');
|
|
4
4
|
|
|
5
|
-
function ServerManager(command) {
|
|
5
|
+
function ServerManager(command, options) {
|
|
6
|
+
const self = this;
|
|
7
|
+
|
|
8
|
+
// Set the command
|
|
9
|
+
self.command = command;
|
|
10
|
+
self.options = options;
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
ServerManager.prototype.monitor = function (command, options) {
|
|
9
14
|
const self = this;
|
|
10
15
|
|
|
11
16
|
return new Promise(async function(resolve, reject) {
|
|
17
|
+
// Use instance properties if arguments are not provided
|
|
18
|
+
command = command || self.command;
|
|
19
|
+
options = options || self.options;
|
|
20
|
+
|
|
21
|
+
// Set the command
|
|
22
|
+
command = command || yargs(hideBin(process.argv)).argv.command || 'npm start';
|
|
23
|
+
|
|
12
24
|
// Set the options
|
|
13
25
|
options = options || {};
|
|
14
26
|
options.log = options.log === undefined ? true : options.log;
|
|
15
27
|
|
|
16
|
-
// Set the command
|
|
17
|
-
self.command = command || yargs(hideBin(process.argv)).argv.command || 'npm start';
|
|
18
|
-
|
|
19
28
|
// Log
|
|
20
|
-
console.log('Starting server...',
|
|
29
|
+
console.log('Starting server...', command);
|
|
21
30
|
|
|
22
31
|
// Start the server
|
|
23
|
-
await powertools.execute(
|
|
32
|
+
await powertools.execute(command, options, (serverProcess) => {
|
|
24
33
|
serverProcess.on('exit', (code) => {
|
|
25
34
|
if (code !== 0) {
|
|
26
35
|
console.log('Server crashed. Restarting...');
|