Пример #1
0
    def setup_watchers(self, cmd_args):
        mask = (pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO
                | pyinotify.IN_CREATE)
        self.watchman = pyinotify.WatchManager()

        event_handler = EventHandler(self.reload_cfg_file,
                                     cmd_filename=self.cmd_args.config_file)
        self.notifier = pyinotify.ThreadedNotifier(self.watchman,
                                                   event_handler)
        self.watchman.add_watch(os.path.dirname(cmd_args.config_file), mask)
Пример #2
0
    PUB = Publisher("tcp://*:" + str(cmd_args.port), "move_it_server")

    mask = (pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO
            | pyinotify.IN_CREATE)
    watchman = pyinotify.WatchManager()

    def reload_cfg_file(filename, disable_backlog=False):
        return reload_config(filename,
                             chains,
                             publisher=PUB,
                             disable_backlog=disable_backlog)

    notifier = pyinotify.ThreadedNotifier(
        watchman,
        EventHandler(reload_cfg_file, cmd_filename=cmd_args.config_file))
    watchman.add_watch(os.path.dirname(cmd_args.config_file), mask)

    def chains_stop(*args):
        global running
        running = False
        notifier.stop()
        terminate(chains, PUB)

    signal.signal(signal.SIGTERM, chains_stop)

    def signal_reload_cfg_file(*args):
        reload_cfg_file(cmd_args.config_file)

    signal.signal(signal.SIGHUP, signal_reload_cfg_file)
Пример #3
0
    LOGGER.info("Starting publisher on port %s.", str(cmd_args.port))

    PUB = Publisher("tcp://*:" + str(cmd_args.port), "move_it_server")

    mask = (pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO
            | pyinotify.IN_CREATE)
    watchman = pyinotify.WatchManager()

    def local_reload_config(filename):
        return reload_config(filename, chains, create_listener_notifier,
                             MirrorRequestManager, PUB)

    notifier = pyinotify.ThreadedNotifier(
        watchman,
        EventHandler(local_reload_config, cmd_filename=cmd_args.config_file))
    watchman.add_watch(os.path.dirname(cmd_args.config_file), mask)

    def chains_stop(*args):
        global running
        running = False
        notifier.stop()
        terminate(chains, PUB)

    signal.signal(signal.SIGTERM, chains_stop)

    def reload_cfg_file(*args):
        reload_config(cmd_args.config_file, chains, create_listener_notifier,
                      MirrorRequestManager, PUB)

    signal.signal(signal.SIGHUP, reload_cfg_file)