@toa.io/cli 1.0.0-alpha.25 → 1.0.0-alpha.26

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": "@toa.io/cli",
3
- "version": "1.0.0-alpha.25",
3
+ "version": "1.0.0-alpha.26",
4
4
  "description": "Toa CLI",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -22,17 +22,17 @@
22
22
  "@toa.io/runtime": "*"
23
23
  },
24
24
  "dependencies": {
25
- "@toa.io/console": "1.0.0-alpha.25",
26
- "@toa.io/generic": "1.0.0-alpha.25",
27
- "@toa.io/kubernetes": "1.0.0-alpha.25",
28
- "@toa.io/norm": "1.0.0-alpha.25",
29
- "@toa.io/operations": "1.0.0-alpha.25",
30
- "@toa.io/yaml": "1.0.0-alpha.25",
25
+ "@toa.io/console": "1.0.0-alpha.26",
26
+ "@toa.io/generic": "1.0.0-alpha.26",
27
+ "@toa.io/kubernetes": "1.0.0-alpha.26",
28
+ "@toa.io/norm": "1.0.0-alpha.26",
29
+ "@toa.io/operations": "1.0.0-alpha.26",
30
+ "@toa.io/yaml": "1.0.0-alpha.26",
31
31
  "dotenv": "16.1.1",
32
32
  "find-up": "5.0.0",
33
33
  "jsonpath": "1.1.1",
34
34
  "paseto": "3.1.4",
35
35
  "yargs": "17.6.2"
36
36
  },
37
- "gitHead": "756ea259f35dda03d45047f8153d441191026877"
37
+ "gitHead": "0ddd9260762d1fe2b8be88eb7b9725e3f7838299"
38
38
  }
@@ -5,6 +5,7 @@ const boot = require('@toa.io/boot')
5
5
  const { version } = require('@toa.io/runtime')
6
6
 
7
7
  const docker = require('./docker')
8
+ const { graceful } = require('./lib/graceful')
8
9
  const { components: find } = require('../util/find')
9
10
 
10
11
  /**
@@ -22,6 +23,8 @@ async function compose (argv) {
22
23
  await composition.connect()
23
24
 
24
25
  if (argv.kill === true) await composition.disconnect()
26
+
27
+ return graceful(composition)
25
28
  }
26
29
 
27
30
  /**
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ function graceful (connector) {
4
+ ['SIGTERM', 'SIGINT']
5
+ .forEach(event => process.once(event, async () => {
6
+ console.info(event)
7
+
8
+ await connector.disconnect()
9
+ }))
10
+ }
11
+
12
+ exports.graceful = graceful
@@ -4,6 +4,7 @@ const boot = require('@toa.io/boot')
4
4
  const { shortcuts } = require('@toa.io/norm')
5
5
  const { directory: { find } } = require('@toa.io/filesystem')
6
6
  const { version } = require('@toa.io/runtime')
7
+ const { graceful } = require('./lib/graceful')
7
8
 
8
9
  const serve = async (argv) => {
9
10
  console.log('Runtime', version)
@@ -22,8 +23,7 @@ const serve = async (argv) => {
22
23
 
23
24
  await service.connect()
24
25
 
25
- // for tests
26
- return service
26
+ return graceful(service)
27
27
  }
28
28
 
29
29
  exports.serve = serve