Exemplo n.º 1
0
Arquivo: agency.py Projeto: f3at/feat
    def _create_pid_file(self):
        rundir = self.config.agency.rundir
        pid_file = run.acquire_pidfile(rundir)

        path = run.write_pidfile(rundir, file=pid_file)
        self.debug("Written pid file %s" % path)
Exemplo n.º 2
0
    def _create_pid_file(self):
        rundir = self.config['agency']['rundir']
        pid_file = run.acquire_pidfile(rundir)

        path = run.write_pidfile(rundir, file=pid_file)
        self.log("Written pid file %s" % path)
Exemplo n.º 3
0
                      help="should deamonize")
    return parser


def sigusr1_handler(_signum, _frame):
    sys.exit(0)


if __name__ == '__main__':
    log.init()
    parser = _create_parser()
    opt, args = parser.parse_args()
    if opt.fail:
        raise CustomException("I'm failing as you have asked.")
    if opt.daemonize:
        logfile = "dummy.log"
        run.daemonize(stdout=logfile, stderr=logfile)

    signal.signal(signal.SIGUSR1, sigusr1_handler)

    rundir = os.path.curdir
    pid_file = run.acquire_pidfile(rundir, "dummy_process")
    path = run.write_pidfile(rundir, file=pid_file)
    print "Written pid file to %s" % (path, )

    try:
        while True:
            pass
    except KeyboardInterrupt:
        pass