Daemonize fix
This commit is contained in:
1 parent
b48e38be97
commit
d38ff40b54
1 file changed
+9
-12
+9
-12
@@ -23,7 +23,7 @@ data_dir = getDataDir()
|
|||||||
|
|
||||||
def start():
|
def start():
|
||||||
try:
|
try:
|
||||||
args = [sys.executable] + sys.argv
|
args = [sys.executable] + [os.path.join(os.environ['PWD'], __file__)] + sys.argv[1:]
|
||||||
new_environ = os.environ.copy()
|
new_environ = os.environ.copy()
|
||||||
new_environ['cp_main'] = 'true'
|
new_environ['cp_main'] = 'true'
|
||||||
|
|
||||||
@@ -55,18 +55,15 @@ def 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(0.1)
|
time.sleep(1)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
from daemon import Daemon
|
|
||||||
class CouchDaemon(Daemon):
|
|
||||||
def run(self):
|
|
||||||
os.environ['cp_main'] = 'true'
|
|
||||||
main()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if options.daemon and options.pid_file:
|
|
||||||
daemon = CouchDaemon(options.pid_file)
|
if options.daemon and options.pid_file and not os.environ.get('cp_main'):
|
||||||
daemon.start()
|
from daemon import Daemon
|
||||||
else:
|
daemon = Daemon(options.pid_file)
|
||||||
main()
|
daemon.daemonize()
|
||||||
|
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user