Merge from trunk
This commit is contained in:
@@ -141,6 +141,7 @@ def _wrapper(func):
|
|||||||
return _wrapped
|
return _wrapped
|
||||||
|
|
||||||
|
|
||||||
|
DEFINE = _wrapper(gflags.DEFINE)
|
||||||
DEFINE_string = _wrapper(gflags.DEFINE_string)
|
DEFINE_string = _wrapper(gflags.DEFINE_string)
|
||||||
DEFINE_integer = _wrapper(gflags.DEFINE_integer)
|
DEFINE_integer = _wrapper(gflags.DEFINE_integer)
|
||||||
DEFINE_bool = _wrapper(gflags.DEFINE_bool)
|
DEFINE_bool = _wrapper(gflags.DEFINE_bool)
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ flags.DEFINE_bool('use_syslog', True, 'output to syslog when daemonizing')
|
|||||||
flags.DEFINE_string('logfile', None, 'log file to output to')
|
flags.DEFINE_string('logfile', None, 'log file to output to')
|
||||||
flags.DEFINE_string('pidfile', None, 'pid file to output to')
|
flags.DEFINE_string('pidfile', None, 'pid file to output to')
|
||||||
flags.DEFINE_string('working_directory', './', 'working directory...')
|
flags.DEFINE_string('working_directory', './', 'working directory...')
|
||||||
|
flags.DEFINE_integer('uid', os.getuid(), 'uid under which to run')
|
||||||
|
flags.DEFINE_integer('gid', os.getgid(), 'gid under which to run')
|
||||||
|
|
||||||
|
|
||||||
def stop(pidfile):
|
def stop(pidfile):
|
||||||
@@ -135,6 +137,8 @@ def daemonize(args, name, main):
|
|||||||
threaded=False),
|
threaded=False),
|
||||||
stdin=stdin,
|
stdin=stdin,
|
||||||
stdout=stdout,
|
stdout=stdout,
|
||||||
stderr=stderr
|
stderr=stderr,
|
||||||
|
uid=FLAGS.uid,
|
||||||
|
gid=FLAGS.gid
|
||||||
):
|
):
|
||||||
main(args)
|
main(args)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Twisted daemon helpers, specifically to parse out gFlags from twisted flags,
|
|||||||
manage pid files and support syslogging.
|
manage pid files and support syslogging.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import gflags
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
@@ -49,6 +50,14 @@ class TwistdServerOptions(ServerOptions):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
class FlagParser(object):
|
||||||
|
def __init__(self, parser):
|
||||||
|
self.parser = parser
|
||||||
|
|
||||||
|
def Parse(self, s):
|
||||||
|
return self.parser(s)
|
||||||
|
|
||||||
|
|
||||||
def WrapTwistedOptions(wrapped):
|
def WrapTwistedOptions(wrapped):
|
||||||
class TwistedOptionsToFlags(wrapped):
|
class TwistedOptionsToFlags(wrapped):
|
||||||
subCommands = None
|
subCommands = None
|
||||||
@@ -79,7 +88,12 @@ def WrapTwistedOptions(wrapped):
|
|||||||
reflect.accumulateClassList(self.__class__, 'optParameters', twistd_params)
|
reflect.accumulateClassList(self.__class__, 'optParameters', twistd_params)
|
||||||
for param in twistd_params:
|
for param in twistd_params:
|
||||||
key = param[0].replace('-', '_')
|
key = param[0].replace('-', '_')
|
||||||
flags.DEFINE_string(key, param[2], str(param[-1]))
|
if len(param) > 4:
|
||||||
|
flags.DEFINE(FlagParser(param[4]),
|
||||||
|
key, param[2], str(param[3]),
|
||||||
|
serializer=gflags.ArgumentSerializer())
|
||||||
|
else:
|
||||||
|
flags.DEFINE_string(key, param[2], str(param[3]))
|
||||||
|
|
||||||
def _absorbHandlers(self):
|
def _absorbHandlers(self):
|
||||||
twistd_handlers = {}
|
twistd_handlers = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user