Write PID file in original process
This ensures that the PID is written, when the process exists.
This commit is contained in:
parent
6ade44c773
commit
360e88f350
@ -128,11 +128,13 @@ def daemonize(configuration, logger):
|
|||||||
configuration.get("server", "pid")) from e
|
configuration.get("server", "pid")) from e
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if pid:
|
if pid:
|
||||||
sys.exit()
|
|
||||||
# Write PID
|
# Write PID
|
||||||
if configuration.get("server", "pid"):
|
if configuration.get("server", "pid"):
|
||||||
with os.fdopen(pid_fd, "w") as pid_file:
|
with os.fdopen(pid_fd, "w") as pid_file:
|
||||||
pid_file.write(str(os.getpid()))
|
pid_file.write(str(pid))
|
||||||
|
sys.exit()
|
||||||
|
if configuration.get("server", "pid"):
|
||||||
|
os.close(pid_fd)
|
||||||
# Decouple environment
|
# Decouple environment
|
||||||
os.chdir("/")
|
os.chdir("/")
|
||||||
os.setsid()
|
os.setsid()
|
||||||
|
Loading…
Reference in New Issue
Block a user