Separate once option into separate command

This commit is contained in:
Jake Howard 2019-09-19 08:59:39 +01:00
parent aedda06ace
commit 532d7309e3
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,4 +1,3 @@
import argparse
import logging import logging
from multiprocessing import Process from multiprocessing import Process
@ -20,17 +19,18 @@ def cli():
@cli.command() @cli.command()
@click.option('--once', is_flag=True) def start():
def start(once): Process(target=run_server, args=(get_server(),)).start()
if once: Process(target=create_scheduler().start).start()
scheduler = create_scheduler()
jobs = {job.func for job in scheduler.get_jobs()}
for job in jobs: @cli.command()
logger.info("Executing '{}'".format(get_callable_name(job))) def once():
job() scheduler = create_scheduler()
else: jobs = {job.func for job in scheduler.get_jobs()}
Process(target=run_server, args=(get_server(),)).start() for job in jobs:
Process(target=create_scheduler().start).start() logger.info("Executing '{}'".format(get_callable_name(job)))
job()
if __name__ == "__main__": if __name__ == "__main__":