nodestatus-server 1.2.7-beta.2 → 1.2.7-beta.4

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.
@@ -3,28 +3,38 @@ const path = require('path');
3
3
 
4
4
  const args = process.argv.slice(2).join(' ');
5
5
 
6
- try {
7
- const pm2 = require('pm2');
8
- pm2.connect(error => {
9
- if (error) {
10
- console.log(error);
11
- process.exit(2);
12
- }
13
- pm2.start(
14
- {
15
- name: 'nodestatus',
16
- script: path.resolve(__dirname, '../build/app.js'),
17
- args
18
- },
19
- error => {
20
- if (error) throw error.message;
21
- pm2.disconnect();
6
+ const cp = require('child_process');
7
+ const { platform } = require('os');
8
+ const { resolve } = require('path');
9
+
10
+ cp.spawn(platform() === 'win32' ? 'npm.cmd' : 'npm', ['run', 'prestart'], {
11
+ env: process.env,
12
+ cwd: resolve(__dirname, '../'),
13
+ stdio: 'inherit'
14
+ }).on('close', () => {
15
+ try {
16
+ const pm2 = require('pm2');
17
+ pm2.connect(error => {
18
+ if (error) {
19
+ console.log(error);
20
+ process.exit(2);
22
21
  }
23
- );
24
- });
25
- } catch (error) {
26
- console.log(`[ERROR]: ${error.message || error}`);
27
- console.log('Something wrong. Please check if you have installed pm2 correctly.');
28
- console.log('Fallback to non-pm2 daemon');
29
- require('./status-server');
30
- }
22
+ pm2.start(
23
+ {
24
+ name: 'nodestatus',
25
+ script: path.resolve(__dirname, '../build/app.js'),
26
+ args
27
+ },
28
+ error => {
29
+ if (error) throw error.message;
30
+ pm2.disconnect();
31
+ }
32
+ );
33
+ });
34
+ } catch (error) {
35
+ console.log(`[ERROR]: ${error.message || error}`);
36
+ console.log('Something wrong. Please check if you have installed pm2 correctly.');
37
+ console.log('Fallback to non-pm2 daemon');
38
+ require('../build/app');
39
+ }
40
+ });
@@ -1,2 +1,11 @@
1
1
  #!/usr/bin/env node
2
- require('../build/app');
2
+
3
+ const cp = require('child_process');
4
+ const { platform } = require('os');
5
+ const { resolve } = require('path');
6
+
7
+ cp.spawn(platform() === 'win32' ? 'npm.cmd' : 'npm', ['run', 'start'], {
8
+ env: process.env,
9
+ cwd: resolve(__dirname, '../'),
10
+ stdio: 'inherit'
11
+ });