Skip to content

Commit

Permalink
Switch to using click in runworker.py`
Browse files Browse the repository at this point in the history
  • Loading branch information
dougthor42 committed May 1, 2019
1 parent 0c74363 commit 4d6ff61
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions runworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,31 @@
import os
from pathlib import Path

import click
from celery.bin import worker

from trendlines.celery_factory import create_celery

# Load our configuration. We're using pathlib and `.resolve()` because
# Flask's working dir is src/trendlines and uses that when running
# `app.config.from_envvar`, so the path it attemps to load is
# `/proj_folder/src/trendlines/config/localhost.cfg` if `cfg_file` is not
# absolute.
cfg_file = Path('./config/localhost.cfg')
os.environ['TRENDLINES_CONFIG_FILE'] = str(cfg_file.resolve())

# app.worker_main()
celery = create_celery()
worker = worker.worker(app=celery)
worker.run()

def runworker():
# Load our configuration. We're using pathlib and `.resolve()` because
# Flask's working dir is src/trendlines and uses that when running
# `app.config.from_envvar`, so the path it attemps to load is
# `/proj_folder/src/trendlines/config/localhost.cfg` if `cfg_file` is not
# absolute.
cfg_file = Path('./config/localhost.cfg')
os.environ['TRENDLINES_CONFIG_FILE'] = str(cfg_file.resolve())

# app.worker_main()
celery = create_celery()
this_worker = worker.worker(app=celery)
this_worker.run()


@click.command()
def main():
runworker()


if __name__ == "__main__":
main()

0 comments on commit 4d6ff61

Please sign in to comment.