Browse Source

Better shutdown and restart

pull/69/head
Ruud 14 years ago
parent
commit
199c17e2c1
  1. 2
      CouchPotato.py
  2. 4
      couchpotato/core/_base/_core/main.py
  3. 7
      couchpotato/runner.py

2
CouchPotato.py

@ -59,5 +59,5 @@ if __name__ == '__main__':
from couchpotato.core.event import fireEvent from couchpotato.core.event import fireEvent
fireEvent('app.crappy_shutdown', single = True) fireEvent('app.crappy_shutdown', single = True)
time.sleep(1) time.sleep(0.1)
sys.exit() sys.exit()

4
couchpotato/core/_base/_core/main.py

@ -46,6 +46,7 @@ class Core(Plugin):
self.urlopen('%sapp.shutdown' % self.createApiUrl(), show_error = False) self.urlopen('%sapp.shutdown' % self.createApiUrl(), show_error = False)
return True return True
except: except:
self.initShutdown()
return False return False
def crappyRestart(self): def crappyRestart(self):
@ -53,6 +54,7 @@ class Core(Plugin):
self.urlopen('%sapp.restart' % self.createApiUrl(), show_error = False) self.urlopen('%sapp.restart' % self.createApiUrl(), show_error = False)
return True return True
except: except:
self.initShutdown(restart = True)
return False return False
def shutdown(self): def shutdown(self):
@ -89,6 +91,8 @@ class Core(Plugin):
try: try:
request.environ.get('werkzeug.server.shutdown')() request.environ.get('werkzeug.server.shutdown')()
except RuntimeError:
pass
except: except:
log.error('Failed shutting down the server: %s' % traceback.format_exc()) log.error('Failed shutting down the server: %s' % traceback.format_exc())

7
couchpotato/runner.py

@ -8,9 +8,7 @@ from werkzeug.contrib.cache import FileSystemCache
import locale import locale
import logging import logging
import os.path import os.path
import socket
import sys import sys
import time
import traceback import traceback
def getOptions(base_path, args): def getOptions(base_path, args):
@ -189,11 +187,6 @@ def runCouchPotato(options, base_path, args, handle = None):
# Go go go! # Go go go!
try: try:
app.run(**config) app.run(**config)
except socket.error:
log.error('Something else is running on the same address')
time.sleep(3)
app.run(**config)
log.error('Something else is running on the same address222')
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
raise raise
except: except:

Loading…
Cancel
Save