@adaptivestone/framework 5.0.0-beta.2 → 5.0.0-beta.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 5.0.0-beta.4
2
+
3
+ [NEW] on shutdown event now after timeout we are forcing to shutdown
4
+
1
5
  ### 5.0.0-beta.2
2
6
 
3
7
  [UPDATE] update deps
@@ -19,11 +19,11 @@ class AbstractCommand extends Base {
19
19
  /**
20
20
  * Get mongo connection name
21
21
  * @param {String} commandName
22
- * @param {array} args
22
+ * @param {object} args
23
23
  * @returns string
24
24
  */
25
25
  static getMongoConnectionName(commandName, args) {
26
- return `CLI: ${commandName} ${args.join(' ')}`;
26
+ return `CLI: ${commandName} ${JSON.stringify(args)}`;
27
27
  }
28
28
 
29
29
  /**
@@ -46,7 +46,13 @@ class AbstractModel extends Base {
46
46
  .connect(this.app.getConfig('mongo').connectionString, connectionParams)
47
47
  .then(
48
48
  () => {
49
- this.logger.info('Mongo connection success');
49
+ this.logger.info(
50
+ `Mongo connection success ${connectionParams.appName}`,
51
+ );
52
+ mongoose.connection.on('error', (err) => {
53
+ this.logger.error('Mongo connection error', err);
54
+ console.error(err);
55
+ });
50
56
 
51
57
  callback();
52
58
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptivestone/framework",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.4",
4
4
  "description": "Adaptive stone node js framework",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/server.js CHANGED
@@ -66,6 +66,15 @@ class Server {
66
66
  models: new Map(),
67
67
  modelConstructors: new Map(),
68
68
  };
69
+
70
+ this.app.events.on('shutdown', () => {
71
+ const forceShutdownTimer = setTimeout(() => {
72
+ console.error('Shutdown timed out, forcing exit');
73
+ process.exit(1);
74
+ }, 5_000);
75
+ // Unref the timer so it doesn't keep the process alive
76
+ forceShutdownTimer.unref();
77
+ });
69
78
  }
70
79
 
71
80
  /**