In Circus, the process and socket manager by mozilla, what is a singleton?

176 Views Asked by At

When configuring watchers, what would be the purpose of including both of these settings under a watching:

singleton = True
numprocess = 1

The documentation states that setting singleton has the following effect:

singleton:

If set to True, this watcher will have at the most one process. Defaults to False.

I read that as negating the need to specify numprocesses however in the github repository they provide an example:

https://github.com/circus-tent/circus/blob/master/examples/example6.ini

Included here as well, where they specify both:

[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557
httpd = True
debug = True
httpd_port = 8080

[watcher:swiss]
cmd = ../bin/python
args = -u flask_app.py
warmup_delay = 0
numprocesses = 1
singleton = True
stdout_stream.class = StdoutStream
stderr_stream.class = StdoutStream

So I would assume they do something different and in some way work together?

1

There are 1 best solutions below

0
On BEST ANSWER

numprocess is the initial number of process for a given watcher. In the example you provided it is set to 1, but a user can typically add more processes as needed.

singleton would only allow a maxiumum of 1 process running for a given watcher, so it would forbid you from increment the number of processes dynamically.

The code below from circus test suite describes it well ::

@tornado.testing.gen_test
def test_singleton(self):
    # yield self._stop_runners()
    yield self.start_arbiter(singleton=True, loop=get_ioloop())

    cli = AsyncCircusClient(endpoint=self.arbiter.endpoint)

    # adding more than one process should fail
    yield cli.send_message('incr', name='test')
    res = yield cli.send_message('list', name='test')
    self.assertEqual(len(res.get('pids')), 1)
    yield self.stop_arbiter()