def shutdown(self, type): if sickbeard.started: # stop all tasks sickbeard.halt() # save all shows to DB sickbeard.saveAll() # shutdown web server if self.webserver: logger.log("Shutting down Tornado") self.webserver.shutDown() try: self.webserver.join(10) except: pass # if run as daemon delete the pidfile if self.runAsDaemon and self.CREATEPID: self.remove_pid_file(self.PIDFILE) if type == sickbeard.events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ('git', 'source'): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == 'win': if hasattr(sys, 'frozen'): # c:\dir\to\updater.exe 12345 c:\dir\to\sickbeard.exe popen_list = [ os.path.join(sickbeard.PROG_DIR, 'updater.exe'), str(sickbeard.PID), sys.executable ] else: logger.log( u"Unknown SR launch method, please file a bug report about this", logger.ERROR) popen_list = [ sys.executable, os.path.join(sickbeard.PROG_DIR, 'updater.py'), str(sickbeard.PID), sys.executable, sickbeard.MY_FULLNAME ] if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if '--nolaunch' not in popen_list: popen_list += ['--nolaunch'] logger.log(u"Restarting SickRage with " + str(popen_list)) logger.shutdown( ) #shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. subprocess.Popen(popen_list, cwd=os.getcwd()) # system exit logger.shutdown() #Make sure the logger has stopped, just in case os._exit(0)
def shutdown(self, type): if sickbeard.started: # stop all tasks sickbeard.halt() # save all shows to DB sickbeard.saveAll() # shutdown web server if self.webserver: logger.log("Shutting down Tornado") self.webserver.shutDown() try: self.webserver.join(10) except: pass # if run as daemon delete the pidfile if self.runAsDaemon and self.CREATEPID: self.remove_pid_file(self.PIDFILE) if type == sickbeard.events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ("git", "source"): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == "win": if hasattr(sys, "frozen"): # c:\dir\to\updater.exe 12345 c:\dir\to\sickbeard.exe popen_list = [ os.path.join(sickbeard.PROG_DIR, "updater.exe"), str(sickbeard.PID), sys.executable, ] else: logger.log(u"Unknown SR launch method, please file a bug report about this", logger.ERROR) popen_list = [ sys.executable, os.path.join(sickbeard.PROG_DIR, "updater.py"), str(sickbeard.PID), sys.executable, sickbeard.MY_FULLNAME, ] if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if "--nolaunch" not in popen_list: popen_list += ["--nolaunch"] logger.log(u"Restarting SickRage with " + str(popen_list)) logger.shutdown() # shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. subprocess.Popen(popen_list, cwd=os.getcwd()) # system exit logger.shutdown() # Make sure the logger has stopped, just in case os._exit(0)
def shutdown(self, event): """ Shut down SickRage :param event: Type of shutdown event, used to see if restart required """ if sickbeard.started: sickbeard.halt() # stop all tasks sickbeard.saveAll() # save all shows to DB # shutdown web server if self.web_server: logger.log('Shutting down Tornado') # pylint: disable=no-member self.web_server.shutDown() try: self.web_server.join(10) except Exception: # pylint: disable=broad-except pass self.clear_cache() # Clean cache # if run as daemon delete the pid file if self.run_as_daemon and self.create_pid: self.remove_pid_file(self.pid_file) if event == sickbeard.event_queue.Events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ('git', 'source'): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == 'win': logger.log( 'You are using a binary Windows build of SickRage. ' # pylint: disable=no-member 'Please switch to using git.', logger.ERROR) if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if '--nolaunch' not in popen_list: popen_list += ['--nolaunch'] logger.log('Restarting SickRage with {options}'.format( options=popen_list)) # pylint: disable=no-member # shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. logger.shutdown() # pylint: disable=no-member subprocess.Popen(popen_list, cwd=os.getcwd()) # Make sure the logger has stopped, just in case logger.shutdown() # pylint: disable=no-member os._exit(0) # pylint: disable=protected-access
def shutdown(self, event): """ Shut down SickRage :param event: Type of shutdown event, used to see if restart required """ if sickbeard.started: sickbeard.halt() # stop all tasks sickbeard.saveAll() # save all shows to DB # shutdown web server if self.web_server: logger.log("Shutting down Tornado") # pylint: disable=no-member self.web_server.shutDown() try: self.web_server.join(10) except Exception: # pylint: disable=broad-except pass self.clear_cache() # Clean cache # if run as daemon delete the pid file if self.run_as_daemon and self.create_pid: self.remove_pid_file(self.pid_file) if event == sickbeard.event_queue.Events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ("git", "source"): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == "win": logger.log( "You are using a binary Windows build of SickRage. " # pylint: disable=no-member "Please switch to using git.", logger.ERROR, ) if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if "--nolaunch" not in popen_list: popen_list += ["--nolaunch"] logger.log("Restarting SickRage with %s" % popen_list) # pylint: disable=no-member # shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. logger.shutdown() # pylint: disable=no-member subprocess.Popen(popen_list, cwd=os.getcwd()) # Make sure the logger has stopped, just in case logger.shutdown() # pylint: disable=no-member os._exit(0) # pylint: disable=protected-access
def shutdown(self, event): if sickbeard.started: # stop all tasks sickbeard.halt() # save all shows to DB sickbeard.saveAll() # shutdown web server if self.webserver: logger.log(u"Shutting down Tornado") self.webserver.shutDown() try: self.webserver.join(10) except Exception: pass # Clean cache self.clear_cache() # if run as daemon delete the pidfile if self.runAsDaemon and self.CREATEPID: self.remove_pid_file(self.PIDFILE) if event == sickbeard.event_queue.Events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ('git', 'source'): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == 'win': logger.log( u"You are using a binary Windows build of SickRage. Please switch to using git.", logger.ERROR) if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if '--nolaunch' not in popen_list: popen_list += ['--nolaunch'] logger.log(u"Restarting SickRage with " + str(popen_list)) logger.shutdown( ) # shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. subprocess.Popen(popen_list, cwd=os.getcwd()) # system exit logger.shutdown() # Make sure the logger has stopped, just in case # pylint: disable=protected-access # Access to a protected member of a client class os._exit(0)
def shutdown(self, event): """ Shut down Medusa :param event: Type of shutdown event, used to see if restart required """ if sickbeard.started: sickbeard.halt() # stop all tasks sickbeard.saveAll() # save all shows to DB # shutdown web server if self.web_server: logger.log('Shutting down Tornado') self.web_server.shutDown() try: self.web_server.join(10) except Exception: # pylint: disable=broad-except pass self.clear_cache() # Clean cache # if run as daemon delete the pid file if self.run_as_daemon and self.create_pid: self.remove_pid_file(self.pid_file) if event == sickbeard.event_queue.Events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ('git', 'source'): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == 'win': logger.log('You are using a binary Windows build of Medusa. ' 'Please switch to using git.', logger.ERROR) if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if '--nolaunch' not in popen_list: popen_list += ['--nolaunch'] logger.log('Restarting Medusa with {options}'.format(options=popen_list)) # shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. logger.shutdown() subprocess.Popen(popen_list, cwd=os.getcwd()) # Make sure the logger has stopped, just in case logger.shutdown() os._exit(0) # pylint: disable=protected-access
def shutdown(self, event): if sickbeard.started: # stop all tasks sickbeard.halt() # save all shows to DB sickbeard.saveAll() # shutdown web server if self.webserver: logger.log(u"Shutting down Tornado") self.webserver.shutDown() try: self.webserver.join(10) except Exception: pass # Clean cache self.clear_cache() # if run as daemon delete the pidfile if self.runAsDaemon and self.CREATEPID: self.remove_pid_file(self.PIDFILE) if event == sickbeard.event_queue.Events.SystemEvent.RESTART: install_type = sickbeard.versionCheckScheduler.action.install_type popen_list = [] if install_type in ('git', 'source'): popen_list = [sys.executable, sickbeard.MY_FULLNAME] elif install_type == 'win': logger.log(u"You are using a binary Windows build of SickRage. Please switch to using git.", logger.ERROR) if popen_list and not sickbeard.NO_RESTART: popen_list += sickbeard.MY_ARGS if '--nolaunch' not in popen_list: popen_list += ['--nolaunch'] logger.log(u"Restarting SickRage with " + str(popen_list)) logger.shutdown() # shutdown the logger to make sure it's released the logfile BEFORE it restarts SR. subprocess.Popen(popen_list, cwd=os.getcwd()) # system exit logger.shutdown() # Make sure the logger has stopped, just in case # pylint: disable=protected-access # Access to a protected member of a client class os._exit(0)