mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
daemon: Integrate checking for an existing pidfile into daemonize_start().
Until now, it has been the responsibility of an individual daemon to call die_if_already_running() at an appropriate time. A long time ago, this had to happen *before* daemonizing, because once the process daemonized itself there was no way to report failure to the process that originally started the daemon. With the introduction of daemonize_start(), this is now possible, but we haven't been taking advantage of it. Therefore, this commit integrates the die_if_already_running() call into daemonize_start() and deletes the calls to it from individual daemons.
This commit is contained in:
@@ -89,9 +89,9 @@ def is_chdir_enabled():
|
||||
return _chdir
|
||||
|
||||
def ignore_existing_pidfile():
|
||||
"""Normally, die_if_already_running() will terminate the program with a
|
||||
message if a locked pidfile already exists. If this function is called,
|
||||
die_if_already_running() will merely log a warning."""
|
||||
"""Normally, daemonize() or daemonize_start() will terminate the program
|
||||
with a message if a locked pidfile already exists. If this function is
|
||||
called, an existing pidfile will be replaced, with a warning."""
|
||||
global _overwrite_pidfile
|
||||
_overwrite_pidfile = True
|
||||
|
||||
@@ -111,7 +111,7 @@ def set_monitor():
|
||||
global _monitor
|
||||
_monitor = True
|
||||
|
||||
def die_if_already_running():
|
||||
def _die_if_already_running():
|
||||
"""If a locked pidfile exists, issue a warning message and, unless
|
||||
ignore_existing_pidfile() has been called, terminate the program."""
|
||||
if _pidfile is None:
|
||||
@@ -343,6 +343,7 @@ def daemonize_start():
|
||||
_monitor_daemon(daemon_pid)
|
||||
# Running in daemon process
|
||||
|
||||
_die_if_already_running()
|
||||
_make_pidfile()
|
||||
|
||||
def daemonize_complete():
|
||||
|
||||
Reference in New Issue
Block a user