mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Fix up daemon start-up code a bit..
This commit is contained in:
parent
0a33931c6b
commit
5f8a1ed971
1 changed files with 10 additions and 15 deletions
|
@ -47,6 +47,7 @@ from optparse import OptionParser
|
||||||
import deluge.log
|
import deluge.log
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
import deluge.error
|
||||||
|
|
||||||
def start_ui():
|
def start_ui():
|
||||||
"""Entry point for ui script"""
|
"""Entry point for ui script"""
|
||||||
|
@ -150,24 +151,14 @@ def start_daemon():
|
||||||
options.loglevel = "none"
|
options.loglevel = "none"
|
||||||
|
|
||||||
if options.config:
|
if options.config:
|
||||||
if not os.path.exists(options.config):
|
if not deluge.configmanager.set_config_dir(options.config):
|
||||||
# Try to create the config folder if it doesn't exist
|
print("There was an error setting the config dir! Exiting..")
|
||||||
try:
|
sys.exit(1)
|
||||||
os.makedirs(options.config)
|
|
||||||
except Exception, e:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if not os.path.exists(deluge.common.get_default_config_dir()):
|
|
||||||
os.makedirs(deluge.common.get_default_config_dir())
|
|
||||||
|
|
||||||
# Sets the options.logfile to point to the default location
|
# Sets the options.logfile to point to the default location
|
||||||
def open_logfile():
|
def open_logfile():
|
||||||
if not options.logfile:
|
if not options.logfile:
|
||||||
if options.config:
|
options.logfile = deluge.configmanager.get_config_dir("deluged.log")
|
||||||
options.logfile = os.path.join(options.config, "deluged.log")
|
|
||||||
else:
|
|
||||||
config_dir = deluge.common.get_default_config_dir()
|
|
||||||
options.logfile = os.path.join(config_dir, "deluged.log")
|
|
||||||
|
|
||||||
# Writes out a pidfile if necessary
|
# Writes out a pidfile if necessary
|
||||||
def write_pidfile():
|
def write_pidfile():
|
||||||
|
@ -196,10 +187,14 @@ def start_daemon():
|
||||||
|
|
||||||
# Setup the logger
|
# Setup the logger
|
||||||
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile)
|
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile)
|
||||||
|
from deluge.log import LOG as log
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from deluge.core.daemon import Daemon
|
from deluge.core.daemon import Daemon
|
||||||
Daemon(options, args)
|
Daemon(options, args)
|
||||||
|
except deluge.error.DaemonRunningError, e:
|
||||||
|
log.error(e)
|
||||||
|
sys.exit(1)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
from deluge.log import LOG as log
|
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue