mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-23 00:03:33 +00:00
Fixed: when receiving a SIGTERM signal, a smooth shutdown procedure should be performed on children processes.
Reverted the change for Python 2
This commit is contained in:
parent
e26f7fc49e
commit
02c3c98cf8
1 changed files with 21 additions and 12 deletions
19
bazarr.py
19
bazarr.py
|
@ -156,7 +156,7 @@ if __name__ == '__main__':
|
|||
pass
|
||||
|
||||
|
||||
def daemon(daemonStatus):
|
||||
def daemon(bazarr_runner = lambda: start_bazarr()):
|
||||
if os.path.exists(stopfile):
|
||||
try:
|
||||
os.remove(stopfile)
|
||||
|
@ -172,9 +172,14 @@ if __name__ == '__main__':
|
|||
except:
|
||||
print('Unable to delete restart file.')
|
||||
else:
|
||||
start_bazarr(daemonStatus)
|
||||
bazarr_runner()
|
||||
|
||||
|
||||
bazarr_runner = lambda: start_bazarr()
|
||||
|
||||
should_stop = lambda: False
|
||||
|
||||
if PY3:
|
||||
daemonStatus = DaemonStatus()
|
||||
|
||||
def shutdown():
|
||||
|
@ -184,9 +189,13 @@ if __name__ == '__main__':
|
|||
os.kill(os.getpid(), signal.SIGINT)
|
||||
|
||||
signal.signal(signal.SIGTERM, lambda signal_no, frame: shutdown())
|
||||
start_bazarr(daemonStatus)
|
||||
|
||||
should_stop = lambda: daemonStatus.should_stop()
|
||||
bazarr_runner = lambda: start_bazarr(daemonStatus)
|
||||
|
||||
bazarr_runner()
|
||||
|
||||
# Keep the script running forever until stop is requested through term or keyboard interrupt
|
||||
while not daemonStatus.should_stop():
|
||||
daemon(daemonStatus)
|
||||
while not should_stop():
|
||||
daemon(bazarr_runner)
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Reference in a new issue