def api_stop_worker(name=None): """ Endpoint for stopping a single worker or all workers. The dynamic path variable <name> is the name of the worker that should be stopped. If no <name> is given, all workers are stopped. """ stop_worker(current_app.config['LIGHTFLOW'], worker_ids=[name] if name is not None else None) return ApiResponse({'success': True})
def worker_stop(obj, worker_ids): """ Stop running workers. \b WORKER_IDS: The IDs of the worker that should be stopped or none to stop them all. """ if len(worker_ids) == 0: msg = 'Would you like to stop all workers?' else: msg = '\n{}\n\n{}'.format('\n'.join(worker_ids), 'Would you like to stop these workers?') if click.confirm(msg, default=True, abort=True): stop_worker(obj['config'], worker_ids=list(worker_ids) if len(worker_ids) > 0 else None)