Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graceful shutdown #458

Closed
wants to merge 2 commits into from
Closed

graceful shutdown #458

wants to merge 2 commits into from

Conversation

endel
Copy link

@endel endel commented Nov 5, 2017

Fixes #457

I noticed when hitting Ctrl-C, this block of code was never called, due to the main process being terminated:

ts-node/src/bin.ts

Lines 59 to 67 in 1d630f9

proc.on('exit', function (code: number, signal: string) {
process.on('exit', function () {
if (signal) {
process.kill(process.pid, signal)
} else {
process.exit(code)
}
})
})

By creating a trap to SIGINT, the main process will be closed only after the child one does.

@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage remained the same at 76.826% when pulling 9051e84 on endel:issue-457 into 1d630f9 on TypeStrong:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 76.826% when pulling 9051e84 on endel:issue-457 into 1d630f9 on TypeStrong:master.

@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage remained the same at 76.826% when pulling 2b94f36 on endel:issue-457 into 1d630f9 on TypeStrong:master.

@stelcheck
Copy link
Contributor

The issue is that while in terminal this will work, IIRC it won't properly propagate signals when daemonized.

@blakeembrey
Copy link
Member

Should be closed with #419, but please let me know if it doesn't!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ts-node doesn't handle graceful shutdown properly
4 participants