msempere / easy_circus

Easy python ZMQ client and library for Mozilla Circus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Easy python ZMQ client and library for Mozilla Circus

Install

python setup.py install

Supported Commands:

  • add
  • decr
  • dstats
  • get
  • globaloptions
  • incr
  • list
  • numprocesses
  • numwatchers
  • options
  • quit
  • reload
  • reloadconfig
  • restart
  • rm
  • set
  • signal
  • start
  • stats
  • status
  • stop

Commands usage:

  • ADD: Add a watcher
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.add_watcher(name="a_watcher", command='ls', args=['-la', '/home'], autostart=True)
True
  • LIST: Get list of watchers or processes in a watcher

Processes in a watcher:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.list(watcher="a_watcher")
[]

List of watchers:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.list()
['a_watcher', 'another_watcher']
  • QUIT: Quit the arbiter immediately
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.quit()
True
  • STOP: Stop the arbiter or a watcher

Stop the arbiter:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.stop()
True

Stop a watcher:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.stop(watcher="a_watcher")
True
  • STATUS: Get the status of a watcher or all watchers

Watcher:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.status(watcher="a_watcher")
'stopped'

All watchers:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.status()
[{'status': 'stopped', 'name': 'another_watcher'}, {'status': 'stopped', 'name': 'a_watcher'}]
  • START: Start the arbiter or a watcher
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.start(watcher="a_watcher")
True
  • DSTATS: Get circusd stats
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.dstats()
{"children": [ ], "cmdline": "python", "cpu": 0.1, "ctime": "0:00.41", "mem": 0.1, "mem_info1": "3M", "mem_info2": "2G", "nice": 0, "pid": 47864, "username": "root"}
  • GET: Get the value of specific watcher options
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.get(["graceful_timeout", "send_hup"])
{"graceful_timeout": 300, "send_hup": True}
  • GLOBALOPTIONS: Get the arbiter options
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.global_options()
{"pubsub_endpoint": "tcp://127.0.0.1:5556", "stats_endpoint": "tcp://127.0.0.1:5557", "endpoint":  "tcp://127.0.0.1:5555", "multicast_endpoint": "udp://222.222.222.222:12027", "check_delay": 5.0}
>>> client.global_options(options=["check_delay", "multicast_endpoint"])
{"check_delay": 5.0, "multicast_endpoint": "udp://222.222.222.222:12027"}
  • RM: Remove a watcher
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.rm_watcher(watcher="a_watcher")
True
  • RESTART: Restart the arbiter or a watcher

Arbiter:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.restart()
True

Watcher:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.restart(watcher="a_watcher")
True
  • RELOADCONFIG: Reload the configuration file
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.reload_configuration()
True
  • RELOAD: Reload the arbiter or a watcher

Arbiter:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.reload()
True

Watcher:

>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.reload(watcher="a_watcher")
True
  • OPTIONS: Get the value of all options for a watcher
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.options(watcher="a_watcher")
{'singleton': False, 'send_hup': False, 'uid': None, 'max_age_variance': 30, 'close_child_stdout': False, 'stderr_stream_conf': None, 'max_retry': 5, 'max_age': 0, 'executable': None, 'graceful_timeout': 30.0, 'copy_env': False, 'use_sockets': False, 'priority': 0, 'working_dir': '/home/msempere/apps/easy_circus', 'gid': None, 'env': None, 'close_child_stderr': False, 'shell': False, 'args': ['-la', '/home'], 'warmup_delay': 0.0, 'on_demand': False, 'stop_signal': 15, 'cmd': 'ls', 'shell_args': None, 'stdout_stream_conf': None, 'numprocesses': 1, 'stop_children': False}
  • NUMWATCHERS: Get the number of watchers
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.num_watchers()
2
  • NUMPROCESSES: Get the number of processes
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.num_processes()
2
  • SET: Set a watcher option
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.set(watcher="a_watcher", options=[("shell", True), ("working_dir", "/home")])
True
  • SIGNAL: Send a signal
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.send_signal(watcher="a_watcher", signum=9)
True
  • STATS: Get process infos
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.stats()`
{"children": [], "cmdline": "python", "cpu": 0.1, "ctime": "0:00.41", "mem": 0.1, "mem_info1": "3M", "mem_info2", "2G", "nice": 0, "pid": 47864, "username": "root"}
  • INCR: Increment the number of processes in a watcher
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.num_processes()
2
>>> client.incr(watcher="a_watcher", num=2)
4
  • decr: Decrement the number of processes in a watcher
>>> from easy_circus.client import Client
>>> client = Client(host='127.0.0.1', port=5555, timeout=15)
>>> client.num_processes()
4
>>> client.decr(watcher="a_watcher", num=1)
3

About

Easy python ZMQ client and library for Mozilla Circus

License:MIT License


Languages

Language:Python 100.0%