11

我正在尝试使用 Gunicorn / nginx / supervisor 部署 Django 1.5,但在这个阶段,我只是想让 Gunicorn 正常启动。

我正在尝试从命令行开始:

gunicorn project.wsgi:application --workers 3 --user=django --group=django --bind=127.0.0.1:8100

它失败了

OSError: [Errno 1] Operation not permitted: '/tmp/wgunicorn-c7BU9r'

追溯:

2013-11-01 20:03:24 [17860] [INFO] Starting gunicorn 18.0
2013-11-01 20:03:24 [17860] [INFO] Listening at: http://127.0.0.1:8000 (17860)
2013-11-01 20:03:24 [17860] [INFO] Using worker: sync
Traceback (most recent call last):
  File "/opt/envs/bedlounge-front/bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')()
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run
    Arbiter(self).run()
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/arbiter.py", line 175, in run
    self.manage_workers()
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/arbiter.py", line 470, in manage_workers
    self.spawn_workers()
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/arbiter.py", line 529, in spawn_workers
    self.spawn_worker()
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/arbiter.py", line 482, in spawn_worker
    self.cfg, self.log)
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/workers/base.py", line 49, in __init__
    self.tmp = WorkerTmp(cfg)
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/workers/workertmp.py", line 25, in __init__
    util.chown(name, cfg.uid, cfg.gid)
  File "/opt/envs/bedlounge-front/lib/python2.7/site-packages/gunicorn/util.py", line 157, in chown
    os.chown(path, uid, gid)
OSError: [Errno 1] Operation not permitted: '/tmp/wgunicorn-c7BU9r'

如果我开始时没有用户和组参数(作为我的普通用户),它开始就好了。我的理解是,我想在另一个用户或组下开始这个。

谁能帮我解决我做错的事情?或者任何可以帮助我解决这个问题的信息?

谢谢!

4

1 回答 1

9

问题可能在于您的用户 ID 尝试以其他用户身份启动该进程。我假设您已经在操作系统中创建了用户和组。您可以以 root 身份尝试之前的命令或使用sudo.

我使用以下主管配置,它在命令行和选项中指定用户:

[program:gunicorn]
command=/opt/mysite/virtual_env/bin/python \
    /opt/mysite/virtual_env/bin/gunicorn_django -w 2 --user=appsrun
directory = /opt/mysite/virtual_env/app/
user = appsrun
于 2013-11-02T09:09:56.430 回答