@imqueue/rpc 1.13.12 → 1.13.14
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 +1 -1
- package/src/IMQClient.js +2 -5
- package/src/IMQService.js +5 -0
- package/src/helpers/pid.d.ts +1 -0
- package/src/helpers/pid.js +7 -1
package/package.json
CHANGED
package/src/IMQClient.js
CHANGED
|
@@ -34,7 +34,6 @@ const events_1 = require("events");
|
|
|
34
34
|
const vm = require("vm");
|
|
35
35
|
process.setMaxListeners(10000);
|
|
36
36
|
const tsOptions = require('../tsconfig.json').compilerOptions;
|
|
37
|
-
const SIGNALS = ['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGBREAK'];
|
|
38
37
|
const RX_SEMICOLON = /;+$/g;
|
|
39
38
|
/**
|
|
40
39
|
* Class IMQClient - base abstract class for service clients.
|
|
@@ -64,13 +63,11 @@ class IMQClient extends events_1.EventEmitter {
|
|
|
64
63
|
this.name = `${baseName}-${(0, _1.osUuid)()}-${this.id}:client`;
|
|
65
64
|
this.serviceName = serviceName || baseName.replace(/Client$/, '');
|
|
66
65
|
this.imq = core_1.default.create(this.name, this.options);
|
|
67
|
-
|
|
66
|
+
_1.SIGNALS.forEach((signal) => process.on(signal, async () => {
|
|
68
67
|
this.destroy().catch(this.logger.error);
|
|
69
68
|
// istanbul ignore next
|
|
70
69
|
setTimeout(() => process.exit(0), core_1.IMQ_SHUTDOWN_TIMEOUT);
|
|
71
|
-
};
|
|
72
|
-
SIGNALS.forEach((signal) => process.on(signal, terminate));
|
|
73
|
-
process.on('exit', terminate);
|
|
70
|
+
}));
|
|
74
71
|
}
|
|
75
72
|
/**
|
|
76
73
|
* Sends call to remote service method
|
package/src/IMQService.js
CHANGED
|
@@ -88,6 +88,11 @@ class IMQService {
|
|
|
88
88
|
this.logger = this.options.logger || /* istanbul ignore next */ console;
|
|
89
89
|
this.imq = core_1.default.create(this.name, this.options);
|
|
90
90
|
this.handleRequest = this.handleRequest.bind(this);
|
|
91
|
+
_1.SIGNALS.forEach((signal) => process.on(signal, async () => {
|
|
92
|
+
this.destroy().catch(this.logger.error);
|
|
93
|
+
// istanbul ignore next
|
|
94
|
+
setTimeout(() => process.exit(0), core_1.IMQ_SHUTDOWN_TIMEOUT);
|
|
95
|
+
}));
|
|
91
96
|
this.imq.on('message', this.handleRequest);
|
|
92
97
|
}
|
|
93
98
|
/**
|
package/src/helpers/pid.d.ts
CHANGED
package/src/helpers/pid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forgetPid = exports.pid = exports.IMQ_PID_DIR = exports.IMQ_TMP_DIR = void 0;
|
|
3
|
+
exports.forgetPid = exports.pid = exports.IMQ_PID_DIR = exports.IMQ_TMP_DIR = exports.SIGNALS = void 0;
|
|
4
4
|
/*!
|
|
5
5
|
* IMQ-RPC helpers: pid, forgetPid
|
|
6
6
|
*
|
|
@@ -20,6 +20,12 @@ exports.forgetPid = exports.pid = exports.IMQ_PID_DIR = exports.IMQ_TMP_DIR = vo
|
|
|
20
20
|
*/
|
|
21
21
|
const path = require("path");
|
|
22
22
|
const fs = require("fs");
|
|
23
|
+
exports.SIGNALS = [
|
|
24
|
+
'SIGTERM',
|
|
25
|
+
'SIGINT',
|
|
26
|
+
'SIGHUP',
|
|
27
|
+
'SIGQUIT',
|
|
28
|
+
];
|
|
23
29
|
exports.IMQ_TMP_DIR = process.env.TMPDIR ||
|
|
24
30
|
// istanbul ignore next
|
|
25
31
|
'/tmp';
|