Example #1
0
    def manage_watchers(self):
        if not self.busy and self.alive:
            self.busy = True
            # manage and reap processes
            self.reap_processes()
            for watcher in self.iter_watchers():
                watcher.manage_processes()

            if self.check_flapping and not self.flapping.is_alive():
                self.flapping = Flapping(self.context, self.endpoint,
                                         self.pubsub_endpoint,
                                         self.check_delay)
                self.flapping.start()

            self.busy = False
Example #2
0
    def initialize(self):
        # set process title
        _setproctitle("circusd")

        # event pub socket
        self.evpub_socket = self.context.socket(zmq.PUB)
        self.evpub_socket.bind(self.pubsub_endpoint)
        self.evpub_socket.linger = 0

        # initialize flapping
        if self.check_flapping:
            self.flapping = Flapping(self.context, self.endpoint,
                                     self.pubsub_endpoint, self.check_delay)

        # initialize watchers
        for watcher in self.iter_watchers():
            self._watchers_names[watcher.name.lower()] = watcher
            watcher.initialize(self.evpub_socket)
Example #3
0
File: show.py Project: almet/circus
    def __init__(self,
                 name,
                 cmd,
                 num_flies=1,
                 warmup_delay=0.,
                 working_dir=None,
                 shell=False,
                 uid=None,
                 gid=None,
                 send_hup=False,
                 env=None,
                 stopped=False,
                 times=2,
                 within=1.,
                 retry_in=7.,
                 max_retry=5):
        self.name = name
        self.num_flies = int(num_flies)
        self.warmup_delay = warmup_delay
        self.cmd = cmd
        self._fly_counter = 0
        self.stopped = stopped
        self.max_retry = max_retry

        self.optnames = ("num_flies", "warmup_delay", "working_dir", "uid",
                         "gid", "send_hup", "shell", "env", "cmd", "times",
                         "within", "retry_in", "max_retry")

        if not working_dir:
            # working dir hasn't been set
            working_dir = util.get_working_dir()

        self.working_dir = working_dir

        self.flies = {}
        self.shell = shell
        self.uid = uid
        self.gid = gid
        self.env = env
        self.send_hup = send_hup

        # define flapping object
        self.flapping = Flapping(self, times, within, retry_in, max_retry)