I am refactoring my code to use celery worker.
Before I used to use argparse to pass command line args.
e.g.
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Node')
parser.add_argument('--environment', action="store", default='local', help="env e.g. production of development")
environment = arg_options.environment
But now I get this error.
celery -A tasks worker --loglevel=info --environment local
celery: error: no such option: --environment
How can I add?
I don't want to use environment variable if I don't have to.
e.g export environment=development
The Celery worker does not execute your __main__
.
If you want to add additional command-line options you can use app.user_options
,
but note that it uses the optparse
module, not argparse
.
See this section in the docs for more:
http://docs.celeryproject.org/en/latest/userguide/extending.html#preload-options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With