Esempio n. 1
0
def exit_cleanup(pidfile: str,
                 server: BaseServer,
                 _signum=None,
                 _frame=None) -> None:
    """ Removes the pidfile before ending the daemon. """
    pidpath = Path(pidfile)

    if not pidpath.is_file():
        return

    with pidpath.open() as f:
        if int(f.read()) == os.getpid():
            LOGGER.info("Shutting-down server ...")
            server.close()
            LOGGER.debug("Finishing daemon process")
            pidpath.unlink()
            sys.exit()
Esempio n. 2
0
def exit_cleanup(
    pidfile: str,
    server: BaseServer,
    daemon: OSPDaemon,
    _signum=None,
    _frame=None,
) -> None:
    """Removes the pidfile before ending the daemon."""
    signal.signal(signal.SIGINT, signal.SIG_IGN)
    pidpath = Path(pidfile)

    if not pidpath.is_file():
        return

    with pidpath.open(encoding='utf-8') as f:
        if int(f.read()) == os.getpid():
            logger.debug("Performing exit clean up")
            daemon.daemon_exit_cleanup()
            logger.info("Shutting-down server ...")
            server.close()
            logger.debug("Finishing daemon process")
            pidpath.unlink()
            sys.exit()