summaryrefslogtreecommitdiffstats
path: root/pyload.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 22:55:07 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 22:55:07 +0200
commit24b6d28baf559e151fc96ce2c15d17dfd78da479 (patch)
tree6dfc34734f3fc10a89ea66304795da4fb51fb7e2 /pyload.py
parentfixing imports when changing cwd (diff)
downloadpyload-24b6d28baf559e151fc96ce2c15d17dfd78da479.tar.xz
fixed start scripts
Diffstat (limited to 'pyload.py')
-rwxr-xr-xpyload.py71
1 files changed, 3 insertions, 68 deletions
diff --git a/pyload.py b/pyload.py
index 19d51ed38..340c35e15 100755
--- a/pyload.py
+++ b/pyload.py
@@ -5,81 +5,16 @@
# Copyright(c) 2008-2013 pyLoad Team
# http://www.pyload.org
#
-# This program is free software: you can redistribute it and/or modify
+# This file is part of pyLoad.
+# pyLoad is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Subjected to the terms and conditions in LICENSE
-#
-# @author: spoob
-# @author: sebnapi
-# @author: RaNaN
-# @author: mkaay
-# @version: v0.5.0
###############################################################################
-import os
-import sys
-from os import _exit
-
-from pyload.Core import Core
-
-def deamon():
- try:
- pid = os.fork()
- if pid > 0:
- sys.exit(0)
- except OSError, e:
- print >> sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
- sys.exit(1)
-
- # decouple from parent environment
- os.setsid()
- os.umask(0)
-
- # do second fork
- try:
- pid = os.fork()
- if pid > 0:
- # exit from second parent, print eventual PID before
- print "Daemon PID %d" % pid
- sys.exit(0)
- except OSError, e:
- print >> sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
- sys.exit(1)
-
- # Iterate through and close some file descriptors.
- for fd in range(0, 3):
- try:
- os.close(fd)
- except OSError: # ERROR, fd wasn't open to begin with (ignored)
- pass
-
- os.open(os.devnull, os.O_RDWR) # standard input (0)
- os.dup2(0, 1) # standard output (1)
- os.dup2(0, 2)
-
- pyload_core = Core()
- pyload_core.start()
-
-
-def main():
- #change name to 'pyLoadCore'
- #from module.lib.rename_process import renameProcess
- #renameProcess('pyLoadCore')
- if "--daemon" in sys.argv:
- deamon()
- else:
- pyload_core = Core()
- try:
- pyload_core.start()
- except KeyboardInterrupt:
- pyload_core.shutdown()
- pyload_core.log.info(_("killed pyLoad from terminal"))
- pyload_core.removeLogger()
- _exit(1)
+from pyload.Core import main
-# And so it begins...
if __name__ == "__main__":
main() \ No newline at end of file