deluge/ui/web/web.py | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py index a2b5765..3d9f1c6 100644 --- a/deluge/ui/web/web.py +++ b/deluge/ui/web/web.py @@ -34,6 +34,8 @@ # import os +import pwd +import grp from deluge.ui.ui import _UI, UI from optparse import OptionGroup @@ -59,6 +61,15 @@ def __init__(self): group.add_option("-f", "--fork", dest="fork", help="Fork the web interface process into the background", action="store_true", default=False) + group.add_option("-P", "--pidfile", dest="pidfile", type="str", + help="Use pidfile to store process id", + action="store", default=None) + group.add_option("-U", "--user", dest="user", type="str", + help="User to switch to. Only use it when starting as root", + action="store", default=None) + group.add_option("-g", "--group", dest="group", type="str", + help="Group to switch to. Only use it when starting as root", + action="store", default=None) group.add_option("-p", "--port", dest="port", type="int", help="Sets the port to be used for the webserver", action="store", default=None) @@ -103,6 +114,19 @@ def start(self): # use that may prevent a filesystem unmount. import deluge.configmanager os.chdir(deluge.configmanager.get_config_dir()) + + if self.options.pidfile: + open(self.options.pidfile, "wb").write("%d\n" % os.getpid()) + + if not deluge.common.windows_check(): + if self.options.group: + if not self.options.group.isdigit(): + self.options.group = grp.getgrnam(self.options.group)[2] + os.setuid(self.options.group) + if self.options.user: + if not self.options.user.isdigit(): + self.options.user = pwd.getpwnam(self.options.user)[2] + os.setuid(self.options.user) import server self.__server = server.DelugeWeb()