部署Django,supervisorctl异常终止
Posted
技术标签:
【中文标题】部署Django,supervisorctl异常终止【英文标题】:Deploying Django, supervisorctl abnormal termination 【发布时间】:2014-06-09 05:25:30 【问题描述】:我正在尝试部署 django。因此,将所有内容安装在干净的 VPS 中。我可以使用 unicorn 运行服务器,但我正在尝试使用 supervisord。所以我像过去一样遵循this 教程,但是现在当我使用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'
【问题讨论】:
看起来您尝试启动进程的用户无权写入文件夹:/opt/myapps/run
是root
用户。关于如何允许写入的任何建议?
你在supervisor中配置的用户不是运行supervisor的用户:Starting uniprogress as uniusr
.
当您在主管中配置[program]
时,您指定了一个用户。那是实际运行该过程的用户。并且应该可以访问该文件夹。
文件夹是/opt/myapps/run
。您应该有一个对该文件夹具有写入权限的组。并将执行用户放在该组中。
【参考方案1】:
问题是用户uniusr
确实没有 有权写入/opt/myapps
。因此,我为解决此问题所做的工作如下。
sudo chown -R uniusr:users /opt/myapps
sudo chmod -R g+w /opt/myapps
【讨论】:
以上是关于部署Django,supervisorctl异常终止的主要内容,如果未能解决你的问题,请参考以下文章