Fix database corruption caused by the miner being restarted during setup.
Install the signal handlers before starting database setup so if the process is terminated part way through it won't actually exit until the event loop is started and the queued signal handler is processed.