Checkworkers
snoop.data.management.commands.checkworkers
#
Command to check health of running workers.
Classes#
Command
#
Health check looking at worker process count.
Will fail if we have less than [snoop.defaultsettings.SNOOP_MIN_WORKERS][] workers running on this node.
Uses good old ps
to get process count, then compares with the value above.
Methods#
handle(self, *args, **options)
#
The actual logic of the command. Subclasses must implement this method.
Source code in snoop/data/management/commands/checkworkers.py
def handle(self, *args, **options):
logging_for_management_command()
cmd = r"ps axo comm,args | grep '^celery .* snoop\.data.*worker' | wc -l"
procs = int(subprocess.check_output(cmd, shell=True).decode())
limit = 1
log.info(f"running worker count on container: {procs}")
log.info(f"out of min {limit}")
assert procs >= limit, 'not enough workers'