本文整理汇总了Python中daemon.DaemonContext.gid方法的典型用法代码示例。如果您正苦于以下问题:Python DaemonContext.gid方法的具体用法?Python DaemonContext.gid怎么用?Python DaemonContext.gid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类daemon.DaemonContext
的用法示例。
在下文中一共展示了DaemonContext.gid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from daemon import DaemonContext [as 别名]
# 或者: from daemon.DaemonContext import gid [as 别名]
def run(self):
logger.info("-- starting mandelbrot agent --")
# execute any privileged subsystem code
self.privilegedStartService()
# set the process title
setproctitle("mandelbrot-agent")
# construct the daemon context
daemon = DaemonContext()
daemon.prevent_core = True
daemon.chroot_directory = None
daemon.working_directory = "/"
if self.pidfile is not None:
daemon.pidfile = TimeoutPIDLockFile(self.pidfile)
if os.getuid() == 0:
daemon.uid = self.uid
daemon.gid = self.gid
elif self.uid is not None or self.gid is not None:
logger.warning("not dropping privileges, process uid is not 0")
# FIXME: hack to ensure that fds stay open when passed to daemon context
daemon.files_preserve = [x for x in xrange(64)]
if self.foreground:
daemon.detach_process = False
daemon.stdin = sys.stdin
daemon.stdout = sys.stdout
daemon.stderr = sys.stderr
else:
daemon.detach_process = True
with daemon:
from twisted.internet import reactor
self.startService()
reactor.run()
logger.info("-- stopping mandelbrot agent --")
self.stopService()
logger.info("-- stopped mandelbrot agent --")
return 0
示例2: start
# 需要导入模块: from daemon import DaemonContext [as 别名]
# 或者: from daemon.DaemonContext import gid [as 别名]
def start(**keywords):
args = {}
args.update(
dev_install = False,
mark_read = None,
debug_level = None,
)
args.update(keywords)
try:
config = democraticd.config.Config(
dev_install = args['dev_install'],
debug_level = args['debug_level'],
mark_read = args['mark_read'],
)
except:
args['dev_install'] = not args['dev_install']
config = democraticd.config.Config(
dev_install = args['dev_install'],
debug_level = args['debug_level'],
mark_read = args['mark_read'],
)
del args['dev_install']
del args['debug_level']
del args['mark_read']
log_file = open(config.log_filename, 'wt+')
context = DaemonContext()
context.uid = config.uid
context.gid = config.gid
context.stdout = log_file
context.stderr = log_file
print('Starting daemon, logging to ' + config.log_filename)
with context:
DemocraticDaemon(config, **args).start()