部署Django时,supervisorctl异常终止

3 投票
1 回答
1754 浏览
提问于 2025-04-18 04:02

我正在尝试部署Django,所以在一个干净的VPS上安装了所有东西。我可以使用unicorn来运行服务器,但我想用supervisord。因此,我按照这个教程进行操作,就像我以前做的那样。但是现在,当我使用sudo supervisorctl start uniprogress启动应用时,出现了一个错误,提示uniprogress: ERROR (abnormal termination)。下面是日志文件的内容。

文件路径:/opt/myapps/logs/gunicorn_supervisor.log

Starting uniprogress as uniusr
2014-04-24 04:54:30 [18053] [INFO] Starting gunicorn 18.0
Traceback (most recent call last):
  File "/opt/myapps/uniprogress/../bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run
    Arbiter(self).run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 172, in run
    self.start()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 134, in start
    self.LISTENERS = create_sockets(self.cfg, self.log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 198, in create_sockets
    sock = sock_type(addr, conf, log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 99, in __init__
    os.remove(addr)
OSError: [Errno 13] Permission denied: '/opt/myapps/run/gunicorn.sock'
Starting uniprogress as uniusr
2014-04-24 04:54:31 [18064] [INFO] Starting gunicorn 18.0
Traceback (most recent call last):
  File "/opt/myapps/uniprogress/../bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run
    Arbiter(self).run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 172, in run
    self.start()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 134, in start
    self.LISTENERS = create_sockets(self.cfg, self.log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 198, in create_sockets
    sock = sock_type(addr, conf, log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 99, in __init__
    os.remove(addr)
OSError: [Errno 13] Permission denied: '/opt/myapps/run/gunicorn.sock'
Starting uniprogress as uniusr
2014-04-24 04:54:31 [18064] [INFO] Starting gunicorn 18.0
Traceback (most recent call last):
  File "/opt/myapps/uniprogress/../bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run
    Arbiter(self).run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 172, in run
    self.start()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 134, in start
    self.LISTENERS = create_sockets(self.cfg, self.log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 198, in create_sockets
    sock = sock_type(addr, conf, log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 99, in __init__
    os.remove(addr)
OSError: [Errno 13] Permission denied: '/opt/myapps/run/gunicorn.sock'
Starting uniprogress as uniusr
2014-04-24 04:54:34 [18075] [INFO] Starting gunicorn 18.0
Traceback (most recent call last):
  File "/opt/myapps/uniprogress/../bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run
    Arbiter(self).run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 172, in run
    self.start()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 134, in start
    self.LISTENERS = create_sockets(self.cfg, self.log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 198, in create_sockets
    sock = sock_type(addr, conf, log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 99, in __init__
    os.remove(addr)
OSError: [Errno 13] Permission denied: '/opt/myapps/run/gunicorn.sock'
Starting uniprogress as uniusr
2014-04-24 04:54:37 [18086] [INFO] Starting gunicorn 18.0
Traceback (most recent call last):
  File "/opt/myapps/uniprogress/../bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==18.0', 'console_scripts', 'gunicorn')()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 71, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 143, in run
    Arbiter(self).run()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 172, in run
    self.start()
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 134, in start
    self.LISTENERS = create_sockets(self.cfg, self.log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 198, in create_sockets
    sock = sock_type(addr, conf, log)
  File "/opt/myapps/local/lib/python2.7/site-packages/gunicorn/sock.py", line 99, in __init__
    os.remove(addr)
OSError: [Errno 13] Permission denied: '/opt/myapps/run/gunicorn.sock'

1 个回答

5

问题是用户 uniusr 没有权限写入 /opt/myapps 这个文件夹。为了修复这个问题,我采取了以下措施。

sudo chown -R uniusr:users /opt/myapps
sudo chmod -R g+w /opt/myapps

撰写回答