tiro-notes 0.27.47 → 0.27.50
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/cli.js +15 -13
- package/package.json +1 -1
- package/shared.helpers.build.js +26 -6
package/cli.js
CHANGED
|
@@ -76,19 +76,21 @@ function startTiroServer (argsObj, cb) {
|
|
|
76
76
|
console.log(`Starting Tiro-Notes from CLI with following arguments : ${JSON.stringify(argsObj)}`);
|
|
77
77
|
|
|
78
78
|
// kill all possible remaining servers of tiro
|
|
79
|
-
tHelpers.killPreviousInstances()
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
tHelpers.killPreviousInstances(() => {
|
|
80
|
+
|
|
81
|
+
// start tiro server, detect success message and get server params
|
|
82
|
+
tHelpers.execCmd('node', [`${__dirname}/server/tiro-server.js`], {
|
|
83
|
+
env: {
|
|
84
|
+
TIRO_PORT: argsObj.port,
|
|
85
|
+
TIRO_HTTPS: argsObj.https
|
|
86
|
+
},
|
|
87
|
+
logName: 'tiroServer',
|
|
88
|
+
onLog: str => {
|
|
89
|
+
tHelpers.checkAndGetTiroConfig(str, {platform: 'cli', cb})
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
});
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
const startSshTunnel = (argsObj) => {
|
package/package.json
CHANGED
package/shared.helpers.build.js
CHANGED
|
@@ -44,6 +44,7 @@ const checkAndGetTiroConfig = (str, p) => {
|
|
|
44
44
|
const execCmd = (cmd, params, p) => {
|
|
45
45
|
if (!p) p = {}
|
|
46
46
|
if (!p.env) p.env = {}
|
|
47
|
+
if (!p.sync) p.sync = false
|
|
47
48
|
if (!p.platform) p.platform = false
|
|
48
49
|
p.logName = !p.logName ? '' : `${p.logName} `
|
|
49
50
|
const log = whichLog(p);
|
|
@@ -51,7 +52,7 @@ const execCmd = (cmd, params, p) => {
|
|
|
51
52
|
log(`[${p.logName}] === ExecCMD ${JSON.stringify({cmd, params, p})}`);
|
|
52
53
|
|
|
53
54
|
let child
|
|
54
|
-
let spawn = require( 'child_process' ).spawn;
|
|
55
|
+
let spawn = p.sync ? require( 'child_process' ).spawnSync : require( 'child_process' ).spawn;
|
|
55
56
|
child = spawn( cmd, params, {env: { ...process.env, ...p.env }});
|
|
56
57
|
|
|
57
58
|
// try {
|
|
@@ -65,14 +66,33 @@ const execCmd = (cmd, params, p) => {
|
|
|
65
66
|
console.log( str );
|
|
66
67
|
if (p && p.onLog) p.onLog(str)
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
+
child.on( 'close', data => {
|
|
70
|
+
const str = `[${p.logName} (${cmd}) ON CLOSE] : ${data}`;
|
|
71
|
+
console.log( str );
|
|
72
|
+
if (p && p.onClose) p.onClose(str)
|
|
73
|
+
});
|
|
69
74
|
return child;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
const killPreviousInstances = () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const killPreviousInstances = (cb) => {
|
|
78
|
+
if (!cb) cb = () => {}
|
|
79
|
+
|
|
80
|
+
// LINUX / MAC => unix like
|
|
81
|
+
const isWin = process.platform.startsWith('win');
|
|
82
|
+
|
|
83
|
+
if (isWin) {
|
|
84
|
+
cb()
|
|
85
|
+
} else {
|
|
86
|
+
// execCmd('sh', ['-c', "ls"], {
|
|
87
|
+
execCmd('sh', ['-c', "ps -ef | grep \'tiro-server.js\' | grep -v grep | awk \'{print $2}\' | xargs -r kill -9"], {
|
|
88
|
+
// execCmd('sh', ['-c', "kill -9 $(ps aux | grep \'tiro-server.js\' | awk '{print $2}' )"], {
|
|
89
|
+
|
|
90
|
+
logName: 'Kill prev tiroServer',
|
|
91
|
+
onClose: () => {
|
|
92
|
+
cb()
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
const e = {
|