diff --git a/SABnzbd.py b/SABnzbd.py index da59655..5991f39 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -1516,9 +1516,7 @@ def main(): # Or special restart cases like Mac and WindowsService if sabnzbd.TRIGGER_RESTART: # Shutdown - cherrypy.engine.exit() - sabnzbd.halt() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() if sabnzbd.downloader.Downloader.do.paused: sabnzbd.RESTART_ARGS.append('-p') @@ -1725,9 +1723,7 @@ if __name__ == '__main__': def stop(self): logging.info('[osx] sabApp Quit - stopping main thread ') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() logging.info('[osx] sabApp Quit - main thread stopped') sabApp = startApp() diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index 09cbaec..fe6cfb4 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -769,7 +769,7 @@ def system_standby(): def shutdown_program(): """ Stop program after halting and saving """ - logging.info("Performing sabnzbd shutdown") + logging.info("[%s] Performing SABnzbd shutdown", misc.caller_name()) sabnzbd.halt() cherrypy.engine.exit() sabnzbd.SABSTOP = True diff --git a/sabnzbd/api.py b/sabnzbd/api.py index 1d34122..ca05e83 100644 --- a/sabnzbd/api.py +++ b/sabnzbd/api.py @@ -589,10 +589,7 @@ def _api_resume(name, output, kwargs): def _api_shutdown(name, output, kwargs): """ API: accepts output """ - logging.info('Shutdown requested by API') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() return report(output) diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index aeb47a6..dd96048 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -463,10 +463,7 @@ class MainPage(object): if pid_in and int(pid_in) != os.getpid(): return "Incorrect PID for this instance, remove PID from URL to initiate shutdown." - logging.info('Shutdown requested by interface') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() return T('SABnzbd shutdown finished') @secured_expose(check_session_key=True) @@ -636,10 +633,7 @@ class Wizard(object): @secured_expose def exit(self, **kwargs): """ Stop SABnzbd """ - logging.info('Shutdown requested by wizard') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() return T('SABnzbd shutdown finished') def get_access_info(): @@ -1030,10 +1024,7 @@ class QueuePage(object): @secured_expose(check_session_key=True) def shutdown(self, **kwargs): - logging.info('Shutdown requested by interface') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() return T('SABnzbd shutdown finished') @secured_expose(check_session_key=True) diff --git a/sabnzbd/osxmenu.py b/sabnzbd/osxmenu.py index 0226479..8b826a2 100644 --- a/sabnzbd/osxmenu.py +++ b/sabnzbd/osxmenu.py @@ -764,10 +764,7 @@ class SABnzbdDelegate(NSObject): self.setMenuTitle_("\n\n%s\n" % (T('Stopping...'))) self.status_item.setHighlightMode_(NO) self.osx_icon = False - logging.info('[osx] application stopping daemon') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() try: notifier.send_notification('SABnzbd', T('SABnzbd shutdown finished'), notifier.NOTIFICATION['other']) except AttributeError: diff --git a/sabnzbd/sabtray.py b/sabnzbd/sabtray.py index dd58906..d14cfb6 100644 --- a/sabnzbd/sabtray.py +++ b/sabnzbd/sabtray.py @@ -166,10 +166,7 @@ class SABTrayThread(SysTrayIconThread): # menu handler - adapted from interface.py def shutdown(self, icon): self.hover_text = self.txt_shutdown - logging.info('Shutdown requested by tray') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() # adapted from interface.py def pause(self): diff --git a/sabnzbd/sabtraylinux.py b/sabnzbd/sabtraylinux.py index a652e06..c1872a1 100644 --- a/sabnzbd/sabtraylinux.py +++ b/sabnzbd/sabtraylinux.py @@ -169,9 +169,7 @@ class StatusIcon(Thread): def shutdown(self, icon): self.hover_text = T('Shutdown') - sabnzbd.halt() - cherrypy.engine.exit() - sabnzbd.SABSTOP = True + sabnzbd.shutdown_program() def pause(self): scheduler.plan_resume(0)