How to start a Celery worker from a script/module __main__?

前端 未结 5 855
离开以前
离开以前 2020-12-13 07:07

I\'ve define a Celery app in a module, and now I want to start the worker from the same module in its __main__, i.e. by running the module with

5条回答
  •  轮回少年
    2020-12-13 07:50

    using app.worker_main method (v3.1.12):

    ± cat start_celery.py
    #!/usr/bin/python
    
    from myapp import app
    
    
    if __name__ == "__main__":
        argv = [
            'worker',
            '--loglevel=DEBUG',
        ]
        app.worker_main(argv)
    

提交回复
热议问题