Example #1
0
def test_register_shutdown(signal_signal):
    def dummy_handler(signal, frame):
        pass

    unix.register_shutdown(dummy_handler)

    assert_true(signal_signal.called)
Example #2
0
def test_register_shutdown(signal_signal):
    def dummy_handler(signal, frame):
        pass

    unix.register_shutdown(dummy_handler)

    assert_true(signal_signal.called)
Example #3
0
    def daemonize(self, args):
        log.setup(self.log_file)
        log.info("Daemonizing.")

        self.before_daemonize(args)

        if unix.still_running(self.name, pid_file_path=self.pid_path):
            log.error("%s still running. Aborting." % self.name)
            sys.exit(1)
        else:
            unix.daemonize(self.name, pid_file_path=self.pid_path)

        def shutdown_handler(signal, frame):
            self.shutdown(signal)
            sys.exit(0)

        unix.register_shutdown(shutdown_handler)

        self.before_jail(args)

        log.info("Setting up the chroot jail to: %s" % self.run_dir)
        unix.chroot_jail(self.run_dir)

        self.before_drop_privs(args)

        unix.drop_privileges(uid_name=self.uid, gid_name=self.gid)

        log.info("Server %s running." % self.name)
        self.start(args)