Rewrite startup/shutdown logic to simplify shutdown signaling. All
cleanup is now run from deferred functions in the main function.
Add two new config options to set the read and write ends of a pair of
pipes. This is used as a simple mechanism for a parent process to
communicate with, observe, and manage the lifetime of a child dcrd
process. When the RX (read end) pipe is closed, clean shutdown
automatically begins.
Add a new flag --lifetimeevents to create and send lifetime event
notifications over the TX (write end) pipe during bringup and
shutdown. This allows the parent process to observe which subsystems
are currently starting, running, and stopping.
Fixes#297.
Fixes#298.
When an OS reboots or shuts down, it sends all processes SIGTERM before
sending SIGKILL. This allows dcrd to do a proper shutdown which most
importantly closes the databases.