Use os.popen2() instead of os.fork() to daemonize.
This commit is contained in:
parent
4ba32dc4bf
commit
bbe31367d4
|
@ -70,7 +70,8 @@ def start_daemon():
|
||||||
version=deluge.common.get_version())
|
version=deluge.common.get_version())
|
||||||
parser.add_option("-p", "--port", dest="port",
|
parser.add_option("-p", "--port", dest="port",
|
||||||
help="Port daemon will listen on", action="store", type="int")
|
help="Port daemon will listen on", action="store", type="int")
|
||||||
|
parser.add_option("-d", "--do-not-daemonize", dest="donot",
|
||||||
|
help="Do not daemonize", action="store_true", default=False)
|
||||||
# Get the options and args from the OptionParser
|
# Get the options and args from the OptionParser
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
@ -81,8 +82,13 @@ def start_daemon():
|
||||||
log.debug("args: %s", args)
|
log.debug("args: %s", args)
|
||||||
|
|
||||||
from deluge.core.daemon import Daemon
|
from deluge.core.daemon import Daemon
|
||||||
|
|
||||||
log.info("Starting daemon..")
|
if options.donot:
|
||||||
pid = os.fork()
|
log.info("Starting daemon..")
|
||||||
if not pid:
|
|
||||||
Daemon(options.port)
|
Daemon(options.port)
|
||||||
|
else:
|
||||||
|
cmd = "deluged -d " + "".join(a for a in args)
|
||||||
|
if options.port != None:
|
||||||
|
cmd = cmd + " -p %s" % options.port
|
||||||
|
|
||||||
|
os.popen2(cmd)
|
||||||
|
|
Loading…
Reference in New Issue