Skip to content

Commit

Permalink
fix: call softClose instead of process.exit when CTRL + C is pressed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenpad authored Feb 21, 2022
1 parent 7b46b77 commit 3cfb63a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 2 additions & 7 deletions lib/preload/soft-exit.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
'use strict'

const SOFT_EXIT_SIGNALS = ['SIGINT', 'SIGTERM']

for (let i = 0; i < SOFT_EXIT_SIGNALS.length; i++) {
process.on(SOFT_EXIT_SIGNALS[i], process.exit)
}

module.exports = { SOFT_EXIT_SIGNALS }
process.on('SIGINT', process.exit)
process.on('SIGTERM', process.exit)
4 changes: 2 additions & 2 deletions platform/linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const debug = require('debug')('0x')
const traceStacksToTicks = require('../lib/trace-stacks-to-ticks')
const { promisify } = require('util')

const { SOFT_EXIT_SIGNALS } = require('../lib/preload/soft-exit')

const {
getTargetFolder,
tidy,
Expand All @@ -18,6 +16,8 @@ const {

module.exports = promisify(linux)

const SOFT_EXIT_SIGNALS = ['SIGINT', 'SIGTERM']

function linux (args, sudo, cb) {
const { status, outputDir, workingDir, name, onPort, pathToNodeBinary } = args
const perf = pathTo('perf')
Expand Down
4 changes: 2 additions & 2 deletions platform/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const { promisify } = require('util')
const rename = promisify(fs.rename)
const sleep = promisify(setTimeout)

const { SOFT_EXIT_SIGNALS } = require('../lib/preload/soft-exit')

const {
getTargetFolder,
spawnOnPort,
Expand All @@ -22,6 +20,8 @@ const {

module.exports = v8

const SOFT_EXIT_SIGNALS = ['SIGINT', 'SIGTERM']

async function v8 (args) {
const { status, outputDir, workingDir, name, onPort, pathToNodeBinary, collectDelay } = args

Expand Down

0 comments on commit 3cfb63a

Please sign in to comment.