@imqueue/rpc 1.13.11 → 1.13.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/rpc",
3
- "version": "1.13.11",
3
+ "version": "1.13.13",
4
4
  "description": "RPC-like client-service implementation over messaging queue",
5
5
  "keywords": [
6
6
  "redis",
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.
@@ -65,14 +64,11 @@ class IMQClient extends events_1.EventEmitter {
65
64
  this.serviceName = serviceName || baseName.replace(/Client$/, '');
66
65
  this.imq = core_1.default.create(this.name, this.options);
67
66
  const terminate = async () => {
68
- try {
69
- await this.destroy();
70
- // istanbul ignore next
71
- setTimeout(() => process.exit(0), 1000);
72
- }
73
- catch (err) { }
67
+ this.destroy().catch(this.logger.error);
68
+ // istanbul ignore next
69
+ setTimeout(() => process.exit(0), core_1.IMQ_SHUTDOWN_TIMEOUT);
74
70
  };
75
- SIGNALS.forEach((signal) => process.on(signal, terminate));
71
+ _1.SIGNALS.forEach((signal) => process.on(signal, terminate));
76
72
  process.on('exit', terminate);
77
73
  }
78
74
  /**
package/src/IMQService.js CHANGED
@@ -88,6 +88,13 @@ 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
+ const terminate = async () => {
92
+ this.destroy().catch(this.logger.error);
93
+ // istanbul ignore next
94
+ setTimeout(() => process.exit(0), core_1.IMQ_SHUTDOWN_TIMEOUT);
95
+ };
96
+ _1.SIGNALS.forEach((signal) => process.on(signal, terminate));
97
+ process.on('exit', terminate);
91
98
  this.imq.on('message', this.handleRequest);
92
99
  }
93
100
  /**
@@ -1,4 +1,5 @@
1
1
  import { ILogger } from '@imqueue/core';
2
+ export declare const SIGNALS: string[];
2
3
  export declare const IMQ_TMP_DIR: string;
3
4
  export declare const IMQ_PID_DIR: string;
4
5
  /**
@@ -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,7 @@ 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 = ['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGBREAK'];
23
24
  exports.IMQ_TMP_DIR = process.env.TMPDIR ||
24
25
  // istanbul ignore next
25
26
  '/tmp';