elasticio-sailor-nodejs 3.0.0-dev5 → 3.0.0-dev7

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/run.js CHANGED
@@ -24,7 +24,6 @@ function prepareSandbox() {
24
24
  }
25
25
 
26
26
  async function putOutToSea(settings, ipc) {
27
- logger.trace({ settings }, 'putOutToSea called');
28
27
  ipc.send('init:started');
29
28
  const deferred = Q.defer();
30
29
  sailorInit = deferred.promise;
@@ -32,7 +31,6 @@ async function putOutToSea(settings, ipc) {
32
31
 
33
32
  //eslint-disable-next-line no-extra-boolean-cast
34
33
  if (!!settings.HOOK_SHUTDOWN) {
35
- logger.trace('Running hook shutdown');
36
34
  disconnectRequired = false;
37
35
  //eslint-disable-next-line no-empty-function
38
36
  sailor.reportError = () => {
@@ -57,6 +55,23 @@ async function putOutToSea(settings, ipc) {
57
55
  ipc.send('init:ended');
58
56
  }
59
57
 
58
+ async function disconnectAndExit() {
59
+ if (!disconnectRequired) {
60
+ return;
61
+ }
62
+ disconnectRequired = false;
63
+
64
+ try {
65
+ logger.info('Disconnecting...');
66
+ await sailor.disconnect();
67
+ logger.info('Successfully disconnected');
68
+ process.exit();
69
+ } catch (err) {
70
+ logger.error(err, 'Unable to disconnect');
71
+ process.exit(-1);
72
+ }
73
+ }
74
+
60
75
  async function gracefulShutdown() {
61
76
  if (!disconnectRequired) {
62
77
  return;
@@ -73,15 +88,8 @@ async function gracefulShutdown() {
73
88
  await sailorInit;
74
89
  logger.trace('Waited an init before graceful shutdown');
75
90
 
76
- try {
77
- logger.info('Disconnecting...');
78
- await sailor.scheduleShutdown();
79
- logger.info('Successfully disconnected');
80
- process.exit();
81
- } catch (err) {
82
- logger.error(err, 'Unable to disconnect');
83
- process.exit(-1);
84
- }
91
+ await sailor.scheduleShutdown();
92
+ await disconnectAndExit();
85
93
  }
86
94
 
87
95
  async function run(settings, ipc) {
@@ -90,7 +98,7 @@ async function run(settings, ipc) {
90
98
  await putOutToSea(settings, ipc);
91
99
  logger.info('Fully initialized and waiting for messages');
92
100
  } catch (e) {
93
- if (sailor && !sailor.isConnected()) {
101
+ if (sailor && !sailor.amqpConnection.closed) {
94
102
  await sailor.reportError(e);
95
103
  }
96
104
  logger.criticalErrorAndExit('putOutToSea.catch', e);
package/config/local.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "LOG_LEVEL": "trace",
3
- "ELASTICIO_FLOW_ID": "692ee23d4ab5d34bb7321559",
4
- "ELASTICIO_EXEC_ID": "exec_67890",
5
- "ELASTICIO_STEP_ID": "step_1",
6
- "ELASTICIO_CONTAINER_ID": "container_abcde",
7
- "ELASTICIO_WORKSPACE_ID": "workspace_xyz",
8
- "ELASTICIO_USER_ID": "user_1122",
9
- "ELASTICIO_COMP_ID": "component_3344",
10
- "ELASTICIO_FUNCTION": "data_trigger",
11
- "ELASTICIO_API_URI": "http://localhost:9000",
12
- "ELASTICIO_API_USERNAME": "task-692ee23d4ab5d34bb7321559",
13
- "ELASTICIO_API_KEY": "976ffec8-455b-494e-9478-2d66761f4040",
14
- "ELASTICIO_MESSAGE_CRYPTO_IV": "0.03091345790184",
15
- "ELASTICIO_MESSAGE_CRYPTO_PASSWORD": "password",
16
- "ELASTICIO_SAILOR_PROXY_URI": "http://localhost:5001",
17
- "ELASTICIO_COMPONENT_PATH": "./spec/component",
18
- "ELASTICIO_EMIT_LIGHTWEIGHT_MESSAGE": "true"
19
- }