Q:

start celery with sudo command

I am working with Celery and I am trying to start it with sudo. sudo celery multi start worker --app=app.celery --loglevel=info --concurrency=1 I need to run the command with sudo, however when I do that I am getting a permission error. How can I start Celery with sudo command?
I have tried to read from the doc's but it's unclear Celery Docs
sudo celery multi start worker --app=app.celery --loglevel=info --concurrency=1
celery multi v4.2.1 (windowlicker)
> Starting nodes...
    > worker@xr-npu-perf-lnx: OK
Traceback (most recent call last):
  File "/auto/pysw/cel7x/python64/3.4.1/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/auto/pysw/cel7x/python64/3.4.1/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/__main__.py", line 20, in <module>
    main()
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/__main__.py", line 16, in main
    _main()
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/celery.py", line 322, in main
    cmd.execute_from_commandline(argv)
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/celery.py", line 496, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/base.py", line 275, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/celery.py", line 488, in handle_argv
    return self.execute(command, argv)
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/celery.py", line 420, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/worker.py", line 222, in run_from_argv
    self.maybe_detach([command] + argv)
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/worker.py", line 229, in maybe_detach
    detached_celeryd(self.app).execute_from_commandline(argv)
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/celeryd_detach.py", line 99, in execute_from_commandline
    **vars(options)
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/bin/celeryd_detach.py", line 35, in detach
    after_forkers=False):
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/platforms.py", line 335, in open
    self.after_chdir()
  File "/auto/nest/xr-perf-site/xr-perf-pyats-env/lib/python3.4/site-packages/celery/platforms.py", line 412, in after_chdir_do
    logfile and open(logfile, 'a').close()
PermissionError: [Errno 13] Permission denied: 'worker.log'

A:

You're running into the permission error because of the location of your log directory.  you can specify the log file with -f.  So maybe something like:
sudo celery multi start worker --app=app.celery --loglevel=info --concurrency=1 -f /tmp/celery.log

should do the trick.  If memory serves, you may also have to set a C_FORCE_ROOT env variable to 1 to get this to work.

