Gunicorn在启动时抛出OSError Errno 1

时间:2013-11-02 00:18:49

标签: django gunicorn

我正在尝试使用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'

如果我没有用户和组参数(作为我的常规用户)启动,它就会很好地启动。我的理解是,我想在另一个用户或组下启动它。

任何人都可以帮我解决我做错的事吗?或者任何有助于我解决此问题的信息?

谢谢!

1 个答案:

答案 0 :(得分:9)

问题可能在于您的用户ID尝试以另一个用户身份启动该进程。我假设你已经在操作系统中创建了用户和组。您可以以root身份尝试以前的命令,也可以使用sudo

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

[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