End plugins before shutdown
This commit is contained in:
1 parent
c670a951cb
commit
044a23764d
2 files changed
+9
-2
No files matched your search
@@ -6,6 +6,7 @@ from os.path import dirname
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
# Root path
|
# Root path
|
||||||
@@ -34,6 +35,8 @@ def start():
|
|||||||
|
|
||||||
subprocess.call(args, env = new_environ)
|
subprocess.call(args, env = new_environ)
|
||||||
return os.path.isfile(os.path.join(base_path, 'restart'))
|
return os.path.isfile(os.path.join(base_path, 'restart'))
|
||||||
|
except KeyboardInterrupt, e:
|
||||||
|
pass
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.critical(e)
|
log.critical(e)
|
||||||
return 0
|
return 0
|
||||||
@@ -52,4 +55,7 @@ if __name__ == '__main__':
|
|||||||
if not restart:
|
if not restart:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
from couchpotato.core.event import fireEvent
|
||||||
|
fireEvent('app.crappy_shutdown', single = True)
|
||||||
|
time.sleep(1)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
@@ -17,13 +17,14 @@ log = CPLog(__name__)
|
|||||||
|
|
||||||
class Core(Plugin):
|
class Core(Plugin):
|
||||||
|
|
||||||
ignore_restart = ['Core.crappyRestart']
|
ignore_restart = ['Core.crappyRestart', 'Core.shutdown']
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addApiView('app.shutdown', self.shutdown)
|
addApiView('app.shutdown', self.shutdown)
|
||||||
addApiView('app.restart', self.restart)
|
addApiView('app.restart', self.restart)
|
||||||
addApiView('app.available', self.available)
|
addApiView('app.available', self.available)
|
||||||
|
|
||||||
|
addEvent('app.crappy_shutdown', self.shutdown)
|
||||||
addEvent('app.crappy_restart', self.crappyRestart)
|
addEvent('app.crappy_restart', self.crappyRestart)
|
||||||
addEvent('app.load', self.launchBrowser, priority = 100)
|
addEvent('app.load', self.launchBrowser, priority = 100)
|
||||||
addEvent('app.base_url', self.createBaseUrl)
|
addEvent('app.base_url', self.createBaseUrl)
|
||||||
@@ -70,7 +71,7 @@ class Core(Plugin):
|
|||||||
|
|
||||||
if brk: break
|
if brk: break
|
||||||
|
|
||||||
time.sleep(300)
|
time.sleep(1)
|
||||||
|
|
||||||
if restart:
|
if restart:
|
||||||
self.createFile(self.restartFilePath(), 'This is the most suckiest way to register if CP is restarted. Ever...')
|
self.createFile(self.restartFilePath(), 'This is the most suckiest way to register if CP is restarted. Ever...')
|
||||||
|
|||||||
Reference in new issue
Block a user