SIGABRT is used by the Go runtime to forcefully terminate all
goroutines, even if they are in a deadlocked state.
It is useful in development (to get a glimpse of any potential race or
hang conditions) and in production to forcefully terminate execution
when a standard SIGQUIT won't do.
This modifies the signal package to _not_ trap SIGABRT and let it be
handled in the standard way by the runtime.
This commit adds a shutdown logger which will send a request for
shutdown on critical errors. It uses the signal package to request safe
shutdown of the daemon. Since we init our logs in config validation,
we add a started channel to the signal package to prevent the case where
we have a critical log after the ShutdownLogger has started but before
the daemon has started listening for intercepts. In this case, we just
ignore the shutdown request.
In this commit, we modify the set of default signals we attempt to catch in
order to execute a graceful shutdown. Before this commit, we would attempt
to catch/register for `SIGSTOP`. There're two issues with this
1. `SIGSTOP` is meant to be used in combination with `SIGCONCT` to allow a
process to be paused/resumed. Therefore, our action of shutting down once
received was incorrect.
2. `SIGSTOP` doesn't exist on windows, so users aren't able to compile on
this platform without modifying the codebase.
In this commit, we modify the primary `signal` package to instead catch
all signals. Before this commit, it would only catch the interrupt
signal sent from the kernel. With this new commit, we'll now also catch
(or attempt to catch): `SIGABRT`, `SIGTERM`, `SIGSTOP`, and `SIGQUIT`.