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()
@cli.command()
def once():
scheduler = create_scheduler() scheduler = create_scheduler()
jobs = {job.func for job in scheduler.get_jobs()} jobs = {job.func for job in scheduler.get_jobs()}
for job in jobs: for job in jobs:
logger.info("Executing '{}'".format(get_callable_name(job))) logger.info("Executing '{}'".format(get_callable_name(job)))
job() job()
else:
Process(target=run_server, args=(get_server(),)).start()
Process(target=create_scheduler().start).start()
if __name__ == "__main__": if __name__ == "__main__":