当前位置: 首页>>代码示例>>Python>>正文


Python daemonize.Daemonize方法代码示例

本文整理汇总了Python中daemonize.Daemonize方法的典型用法代码示例。如果您正苦于以下问题:Python daemonize.Daemonize方法的具体用法?Python daemonize.Daemonize怎么用?Python daemonize.Daemonize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在daemonize的用法示例。


在下文中一共展示了daemonize.Daemonize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def __init__(self, name, chromedriver_path='chromedriver'):
    # Setup objects
    self._run_event = threading.Event()
    self._stop_event = threading.Event()
    self._thread = None
    self._chromedriver_path = chromedriver_path
    self._daemon = None
    self._name = name
    self._started = False

    # Parse config
    self._config = self._parse_config()
    if self._config.daemon:
      user = self._config.user if os.geteuid() == 0 else None
      group = self._config.group if os.geteuid() == 0 else None
      self._daemon = daemonize.Daemonize(
          name,
          pid=self._config.pidfile,
          action=self._start_internal,
          user=user,
          group=group) 
开发者ID:Matir,项目名称:pwnableweb,代码行数:23,代码来源:client.py

示例2: watch

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def watch(daemon):
    """
    Watches for figures.
    """
    if platform.system() == 'Linux':
        watcher_cmd = watch_daemon_inotify
    else:
        watcher_cmd = watch_daemon_fswatch

    if daemon:
        daemon = Daemonize(app='inkscape-figures',
                           pid='/tmp/inkscape-figures.pid',
                           action=watcher_cmd)
        daemon.start()
        log.info("Watching figures.")
    else:
        log.info("Watching figures.")
        watcher_cmd() 
开发者ID:gillescastel,项目名称:inkscape-figures,代码行数:20,代码来源:main.py

示例3: main

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def main():
    args = parse_arguments()

    qrl_dir_post_fix = ''
    copy_files = []
    if args.network_type == 'testnet':
        qrl_dir_post_fix = '-testnet'
        package_directory = os.path.dirname(os.path.abspath(__file__))
        copy_files.append(os.path.join(package_directory, '../network/testnet/genesis.yml'))
        copy_files.append(os.path.join(package_directory, '../network/testnet/config.yml'))

    config.user.qrl_dir = os.path.expanduser(os.path.normpath(args.qrl_dir) + qrl_dir_post_fix)
    config.create_path(config.user.qrl_dir, copy_files)
    config.user.load_yaml(config.user.config_path)

    daemon = Daemonize(app="qrl_walletd", pid=pid, action=run)
    daemon.start() 
开发者ID:theQRL,项目名称:QRL,代码行数:19,代码来源:walletd.py

示例4: _run_op_in_background

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def _run_op_in_background(run, op, pidfile, quiet, stop_after, extra_env):
    import daemonize

    action = lambda: _run_op(run, op, quiet, stop_after, extra_env)
    daemon = daemonize.Daemonize(
        app="guild_op", action=action, pid=pidfile, chdir=config.cwd()
    )
    # Need to log before starting daemon, otherwise output isn't
    # visible.
    if not quiet:
        log.info(
            "%s started in background as %s (pidfile %s)",
            run.opref.to_opspec(config.cwd()),
            run.id,
            pidfile,
        )
    try:
        daemon.start()
    except SystemExit:
        op_util.clear_run_pending(run)
        raise 
开发者ID:guildai,项目名称:guildai,代码行数:23,代码来源:op.py

示例5: _start

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def _start(name, f, log):
    import daemonize

    pidfile = var.pidfile(name)
    if os.path.exists(pidfile):
        raise Running(name, pidfile)
    util.ensure_dir(os.path.dirname(pidfile))
    # Save original log level to workaround issue with daemonization
    # (see note in _run).
    log_level = log.getEffectiveLevel()
    daemon = daemonize.Daemonize(
        app=name,
        action=lambda: _run(f, log, log_level),
        pid=pidfile,
        keep_fds=_log_fds(log),
    )
    daemon.start() 
开发者ID:guildai,项目名称:guildai,代码行数:19,代码来源:service.py

示例6: main

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def main(argv=None):
    mod_docstring = sys.modules[__name__].__doc__
    arg_parser = ArgumentParser(
        description=mod_docstring,
        formatter_class=RawDescriptionHelpFormatter,
    )
    PulsarConfigBuilder.populate_options(arg_parser)
    args = arg_parser.parse_args(argv)

    pid_file = args.pid_file

    log.setLevel(logging.DEBUG)
    log.propagate = False

    if args.daemonize:
        if Daemonize is None:
            raise ImportError(REQUIRES_DAEMONIZE_MESSAGE)

        keep_fds = []
        if args.daemon_log_file:
            fh = logging.FileHandler(args.daemon_log_file, "w")
            fh.setLevel(logging.DEBUG)
            log.addHandler(fh)
            keep_fds.append(fh.stream.fileno())
        else:
            fh = logging.StreamHandler(sys.stderr)
            fh.setLevel(logging.DEBUG)
            log.addHandler(fh)

        daemon = Daemonize(
            app="pulsar",
            pid=pid_file,
            action=functools.partial(app_loop, args, log),
            verbose=DEFAULT_VERBOSE,
            logger=log,
            keep_fds=keep_fds,
        )
        daemon.start()
    else:
        app_loop(args, log) 
开发者ID:galaxyproject,项目名称:pulsar,代码行数:42,代码来源:main.py

示例7: main

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def main():
    parser = argparse.ArgumentParser(description='cstar_perf_notifications')
    parser.add_argument('-F', '--foreground', dest='foreground', 
                        action='store_true', help='Run in the foreground instead of daemonizing')
    parser.add_argument('--pid', default="/tmp/cstar_perf_notifications.pid", 
                        help='PID file for daemon', dest='pid')
    parser.add_argument('-l', '--log', default='/tmp/cstar_perf_notifications.log',
                        help='File to log to', dest='logfile')
    parser.add_argument('-v', '--verbose', action='store_true',
                        help='Print log messages', dest='verbose')
    args = parser.parse_args()

    log.setLevel(logging.DEBUG)
    log.propagate = False
    fh = logging.FileHandler(args.logfile, "a")
    formatter = logging.Formatter("%(levelname)s:%(funcName)s:%(asctime) -8s %(message)s")
    fh.setFormatter(formatter)
    fh.setLevel(logging.DEBUG)
    log.addHandler(fh)
    if args.verbose:
        sh = logging.StreamHandler()
        sh.setFormatter(formatter)
        sh.setLevel(logging.DEBUG)
        log.addHandler(sh)
    keep_fds = [fh.stream.fileno()]


    if args.foreground:
        multi_service()
    else:
        daemon = Daemonize(app="notifications", pid=args.pid, action=multi_service, keep_fds=keep_fds)
        daemon.start() 
开发者ID:datastax,项目名称:cstar_perf,代码行数:34,代码来源:notifications.py

示例8: _parse_config

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def _parse_config(self):
    parser = argparse.ArgumentParser(description='Vulnerable Client')
    parser.add_argument('--user', help='Drop privileges to this user.',
        default='nobody')
    parser.add_argument('--group', help='Drop privileges to this group.',
        default='nogroup')
    parser.add_argument('--nodaemon', help='Daemonize.', action='store_false',
        dest='daemon')
    parser.add_argument('--pidfile', help='Write pid to file.',
        default='/tmp/%s.pid' % self._name)
    return parser.parse_args() 
开发者ID:Matir,项目名称:pwnableweb,代码行数:13,代码来源:client.py

示例9: run

# 需要导入模块: import daemonize [as 别名]
# 或者: from daemonize import Daemonize [as 别名]
def run():
    global args

    logger = None
    args = parse_args()

    if args.stop:
        stop_daemon(args)
        sys.exit(0)

    if os.getuid() == 0:
        if args.as_root:
            print("The daemon is being run as root.")
        else:
            print("The daemon should not be run as root. If you have a good reason to do so, use the --as-root flag.")
            sys.exit(1)

    if args.respawn:
        stop_daemon(args)
        time.sleep(3)

    # daemonize logs exceptions to its logger (which defaults to the syslog)
    # and does not make them appear on stdout/stderr. If we're in foreground
    # mode, override that logger with our own.
    if args.foreground:
        logger = logging.getLogger('run-daemon')
        if args.verbose:
            logger.setLevel(logging.DEBUG)

    install_example_config_file(args.config)

    os.makedirs(args.run_dir, exist_ok=True)
    daemon = Daemonize(app="openrazer-daemon",
                       pid=os.path.join(args.run_dir, "openrazer-daemon.pid"),
                       action=run_daemon,
                       foreground=args.foreground,
                       verbose=args.verbose,
                       chdir=args.run_dir,
                       logger=logger)
    daemon.start() 
开发者ID:openrazer,项目名称:openrazer,代码行数:42,代码来源:run_openrazer_daemon.py


注:本文中的daemonize.Daemonize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。