Exercise pidfile before daemonizing

This is one of the few errors that can cause us to silently
fail to start.

Change-Id: Id5dbf737f55770d77e76fe94f72c2e39b9891dae
This commit is contained in:
James E. Blair 2018-02-08 08:58:21 -08:00
parent 4991bd5745
commit 08409fb2fa
1 changed files with 5 additions and 0 deletions

View File

@ -166,6 +166,11 @@ class NodepoolDaemonApp(NodepoolApp):
if is_pidfile_stale(pid):
pid.break_lock()
# Exercise the pidfile before we do anything else (including
# logging or daemonizing)
with pid:
pass
with daemon.DaemonContext(pidfile=pid):
return super(NodepoolDaemonApp, self)._do_run()