@nginstack/engine-node 59.0.15 → 60.0.5
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/README.md +1 -1
- package/lib/Engine.js +33 -28
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/Engine.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const child_process = require('child_process');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
|
-
const url = require('url');
|
|
5
4
|
const del = require('del');
|
|
6
5
|
const request = require('request');
|
|
7
6
|
const getPort = require('get-port');
|
|
@@ -15,7 +14,7 @@ const net = require('net');
|
|
|
15
14
|
|
|
16
15
|
tmp.setGracefulCleanup();
|
|
17
16
|
|
|
18
|
-
const ENGINE_APP = '
|
|
17
|
+
const ENGINE_APP = os.platform() == 'win32' ? 'engine64.exe' : 'engine';
|
|
19
18
|
const NGINT_APP_PATH = '/bin/win64/ngint.exe';
|
|
20
19
|
const EXIT_CODE_RESTART_REQUIRED = 4;
|
|
21
20
|
const ENGINE_STATUS_URL = '/api/service-status/v1/status';
|
|
@@ -125,12 +124,7 @@ class Engine {
|
|
|
125
124
|
this.monitorTimeoutId_ = null;
|
|
126
125
|
}
|
|
127
126
|
this.monitorEnabled_ = true;
|
|
128
|
-
request.get(
|
|
129
|
-
protocol: 'http',
|
|
130
|
-
hostname: 'localhost',
|
|
131
|
-
port: this.httpPort,
|
|
132
|
-
pathname: ENGINE_STATUS_URL
|
|
133
|
-
}), (error, response) => {
|
|
127
|
+
request.get(`http://localhost:${this.httpPort}${ENGINE_STATUS_URL}`, (_error, response) => {
|
|
134
128
|
if (response && response.statusCode) {
|
|
135
129
|
this.lastStatusCode_ = response.statusCode;
|
|
136
130
|
if (this.lastStatusCode_ === 500) {
|
|
@@ -250,9 +244,12 @@ class Engine {
|
|
|
250
244
|
if (!httpUrl.startsWith('http://') && !httpUrl.startsWith('https://')) {
|
|
251
245
|
httpUrl = 'http://' + httpUrl;
|
|
252
246
|
}
|
|
253
|
-
request.get(
|
|
247
|
+
request.get(new URL(ENGINE_DOWNLOAD_URL, httpUrl).toString())
|
|
254
248
|
.pipe(fs.createWriteStream(this.enginePath))
|
|
255
249
|
.on('close', () => {
|
|
250
|
+
if (os.platform() != 'win32') {
|
|
251
|
+
fs.chmodSync(path.join(this.installPath, ENGINE_APP), '755');
|
|
252
|
+
}
|
|
256
253
|
resolve();
|
|
257
254
|
})
|
|
258
255
|
.on('error', (reqErr) => {
|
|
@@ -329,10 +326,12 @@ class Engine {
|
|
|
329
326
|
args.push('--additionalLoggerConfig=\'' + logConfig + '\'');
|
|
330
327
|
}
|
|
331
328
|
|
|
332
|
-
this.process_ = child_process.spawn(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
329
|
+
this.process_ = child_process.spawn(path.join(this.installPath, ENGINE_APP),
|
|
330
|
+
args,
|
|
331
|
+
{
|
|
332
|
+
cwd: this.installPath,
|
|
333
|
+
windowsHide: true
|
|
334
|
+
});
|
|
336
335
|
|
|
337
336
|
this.process_.on('error', (err) => {
|
|
338
337
|
console.error('Error starting Engine process:', err);
|
|
@@ -438,21 +437,27 @@ class Engine {
|
|
|
438
437
|
sendShutdownCommand_() {
|
|
439
438
|
if (this.process_) {
|
|
440
439
|
let forceKill = true;
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
440
|
+
if (os.platform() == 'win32') {
|
|
441
|
+
if (fs.existsSync(this.ngintPath_)) {
|
|
442
|
+
try {
|
|
443
|
+
console.info('Shutdown command sent to Engine process');
|
|
444
|
+
child_process.execFileSync(
|
|
445
|
+
this.ngintPath_,
|
|
446
|
+
['shutdown', this.process_.pid, ENGINE_SHUTDOWN_TIMEOUT],
|
|
447
|
+
{
|
|
448
|
+
cwd: this.installPath,
|
|
449
|
+
windowsHide: true
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
forceKill = false;
|
|
453
|
+
} catch (e) {
|
|
454
|
+
console.error('Error stopping Engine', e);
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
console.info('ngint was not found');
|
|
455
458
|
}
|
|
459
|
+
} else {
|
|
460
|
+
process.kill(this.process_.pid, 'SIGTERM');
|
|
456
461
|
}
|
|
457
462
|
if (forceKill) {
|
|
458
463
|
console.info('Kill signal sent to Engine process');
|
|
@@ -506,7 +511,7 @@ class Engine {
|
|
|
506
511
|
const hash = crypto.createHash('sha256');
|
|
507
512
|
hash.update(os.hostname());
|
|
508
513
|
hash.update(getWorkspacePath());
|
|
509
|
-
return ('_' + hash.digest('hex').toUpperCase()).
|
|
514
|
+
return ('_' + hash.digest('hex').toUpperCase()).substring(0, INSTANCE_ID_LENGTH);
|
|
510
515
|
}
|
|
511
516
|
}
|
|
512
517
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nginstack/engine-node",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "60.0.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"thread-sleep": "^2.2.0",
|
|
25
25
|
"tmp": "^0.2.1"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "ac2f2455aca88917f9e76fa2214f82f9fa9ef1c1"
|
|
28
28
|
}
|