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