@nginstack/engine-node 60.0.4 → 60.0.11

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.
Files changed (2) hide show
  1. package/lib/Engine.js +34 -19
  2. package/package.json +2 -2
package/lib/Engine.js CHANGED
@@ -78,6 +78,7 @@ class Engine {
78
78
  this.v8_ = options.v8 || false;
79
79
  this.startupTimeout = options.startupTimeout || ENGINE_STARTUP_TIMEOUT;
80
80
  this.startedSuccessfully = false;
81
+ this.inShutdown_ = false;
81
82
  this.redirectLogsToStdout_ = options.redirectLogsToStdout || false;
82
83
  this.onEngineClose_ = null;
83
84
  if (options.instanceId) {
@@ -127,7 +128,7 @@ class Engine {
127
128
  request.get(`http://localhost:${this.httpPort}${ENGINE_STATUS_URL}`, (_error, response) => {
128
129
  if (response && response.statusCode) {
129
130
  this.lastStatusCode_ = response.statusCode;
130
- if (this.lastStatusCode_ === 500) {
131
+ if (this.lastStatusCode_ === 500 && !this.inShutdown_) {
131
132
  console.info(`Engine response (${response.statusCode}):\n${response.body}`);
132
133
  }
133
134
  } else {
@@ -247,6 +248,9 @@ class Engine {
247
248
  request.get(new URL(ENGINE_DOWNLOAD_URL, httpUrl).toString())
248
249
  .pipe(fs.createWriteStream(this.enginePath))
249
250
  .on('close', () => {
251
+ if (os.platform() != 'win32') {
252
+ fs.chmodSync(path.join(this.installPath, ENGINE_APP), '755');
253
+ }
250
254
  resolve();
251
255
  })
252
256
  .on('error', (reqErr) => {
@@ -323,10 +327,13 @@ class Engine {
323
327
  args.push('--additionalLoggerConfig=\'' + logConfig + '\'');
324
328
  }
325
329
 
326
- this.process_ = child_process.spawn(ENGINE_APP, args, {
327
- cwd: this.installPath,
328
- windowsHide: true
329
- });
330
+ this.inShutdown_ = false;
331
+ this.process_ = child_process.spawn(path.join(this.installPath, ENGINE_APP),
332
+ args,
333
+ {
334
+ cwd: this.installPath,
335
+ windowsHide: true
336
+ });
330
337
 
331
338
  this.process_.on('error', (err) => {
332
339
  console.error('Error starting Engine process:', err);
@@ -417,6 +424,7 @@ class Engine {
417
424
  } else {
418
425
  resolve();
419
426
  }
427
+ this.inShutdown_ = false;
420
428
  };
421
429
  this.sendShutdownCommand_();
422
430
  } else {
@@ -432,21 +440,28 @@ class Engine {
432
440
  sendShutdownCommand_() {
433
441
  if (this.process_) {
434
442
  let forceKill = true;
435
- if (fs.existsSync(this.ngintPath_)) {
436
- try {
437
- console.info('Shutdown command sent to Engine process');
438
- child_process.execFileSync(
439
- this.ngintPath_,
440
- ['shutdown', this.process_.pid, ENGINE_SHUTDOWN_TIMEOUT],
441
- {
442
- cwd: this.installPath,
443
- windowsHide: true
444
- }
445
- );
446
- forceKill = false;
447
- } catch (e) {
448
- console.error('Error stopping Engine', e);
443
+ this.inShutdown_ = true;
444
+ if (os.platform() == 'win32') {
445
+ if (fs.existsSync(this.ngintPath_)) {
446
+ try {
447
+ console.info('Shutdown command sent to Engine process');
448
+ child_process.execFileSync(
449
+ this.ngintPath_,
450
+ ['shutdown', this.process_.pid, ENGINE_SHUTDOWN_TIMEOUT],
451
+ {
452
+ cwd: this.installPath,
453
+ windowsHide: true
454
+ }
455
+ );
456
+ forceKill = false;
457
+ } catch (e) {
458
+ console.error('Error stopping Engine', e);
459
+ }
460
+ } else {
461
+ console.info('ngint was not found');
449
462
  }
463
+ } else {
464
+ process.kill(this.process_.pid, 'SIGTERM');
450
465
  }
451
466
  if (forceKill) {
452
467
  console.info('Kill signal sent to Engine process');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nginstack/engine-node",
3
- "version": "60.0.4",
3
+ "version": "60.0.11",
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": "04220d66e188e03f53186458381d4303124a227a"
27
+ "gitHead": "c2184d7ad379106cbee093a0aecccc4e56366c80"
28
28
  }