Python Celery init.d 脚本 OSError: [Errno 1] 操作不允许

1 投票
1 回答
2190 浏览
提问于 2025-04-18 07:52

当我启动 /etc/init.d/celeryd 时,出现了下面的错误。我确保了所有的目录对我用来启动它的用户都是可读可写的。我甚至在所有需要写入文件的地方都用 touch 命令创建了一个空文件,以确保可以写入。

(community)community@community:~$ /etc/init.d/celeryd  start
bot_server.settings.production
celery multi v3.1.11 (Cipater)
> Starting nodes...
    > w1.bot_server@community.net: Traceback (most recent call last):
  File "/home/community/community-forums/bot_server/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd_detach.py", line 26, in run_from_argv
    detached().execute_from_commandline(argv)
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/celery/bin/celeryd_detach.py", line 160, in execute_from_commandline
    **vars(options)
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/celery/bin/celeryd_detach.py", line 42, in detach
    with detached(logfile, pidfile, uid, gid, umask, working_directory, fake):
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/celery/platforms.py", line 383, in detached
    maybe_drop_privileges(uid=uid, gid=gid)
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/celery/platforms.py", line 520, in maybe_drop_privileges
    initgroups(uid, gid)
  File "/home/community/.virtualenvs/community/local/lib/python2.7/site-packages/celery/platforms.py", line 473, in initgroups
    return os.initgroups(username, gid)
OSError: [Errno 1] Operation not permitted
* Child terminated with errorcode 1
FAILED

我正在使用:

Django==1.6.3
celery==3.1.11
celerymon==1.0.3
django-celery==3.1.10
django-celery-with-redis==3.0

1 个回答

2

OSError errno 1 看起来像是权限问题:OSError: [错误 1] 操作不被允许

问题似乎出在 os.initgroups 上,它会在系统上调用 initgroups -- 可以查看 man initgroups 来了解更多。

根据你的提示,看起来你在使用某种角色账户,我猜可能是你的角色或组的权限设置有问题,导致 django 无法访问某些文件。

编辑:来自 man initgroups

DESCRIPTION
   The initgroups() function initializes the group access list by reading
   the group database /etc/group and using all groups of which user is a member.
   The additional group group is also added to the list.

可以让 community 读取 /etc/group 吗?

撰写回答