-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
nodemon -v
: 2.0.3node -v
: v13.13.0- Operating system/terminal environment: Void Linux / kitty + fish.
- Using Docker? Nop.
- Command you ran:
npx nodemon
This is not a bug, but rather a discussion on how to handle signals.
Heavely related to #1667.
Actual behaviour
Currently, it’s quite a mess ( ͡° ͜ʖ ͡°).
Basics
to close
, to end
, to exit
, to quit
, to stop
, to terminate
, to shut down
, a bit confusing isn’t it?
Let me quote the official documentation.
SIGTERM
:
It is the normal way to politely ask a program to terminate.
The shell command kill generates SIGTERM by default.
SIGQUIT
:
Certain kinds of cleanups are best omitted in handling SIGQUIT.
SIGHUP
:
[…] used to report that the user’s terminal is disconnected
Expected behaviour
This is rather debatable, but here I go.
When nodmeon receives SIGINT or SIGHUP, it should pass the signal to the child process, and if the process does not quit after X seconds, nodemon should ignore the signal. This way, the child process is free to do whatever it wants (e.g. reload config or gracefully quit). If the child stops before the timeout, nodemon should also stops. This should solves #1661. Also, if SIGINT is received before timeout, SIGKILL is sent to the child. This way, the user can forcefully quit with two ^C
.
When nodemon receives SIGTERM, it should pass the signal to the child process, and if the process does not quit after X seconds, send SIGKILL to the child, then quit nodemon. This is the behaviour of systemd and it simplifies integration with system’s init.
When nodmeon receives SIGQUIT, it should immediatly SIGKILL the child, then quit nodemon. This way, no cleaning is done by the child.
Also, the restart should be interpretad more as a realod. This way, we can specify a reloadSignal
(set to SIGHUP by default) which is sent each time a change is detected by watch or user types restart
. nodemon should not use (implicitely at least) SIGUSR2 since it’s a user-defined condition (aka. reserved for the child process for other tasks).
We should also add a timeout
config to set the value used by nodemon.
WDYT?