为什么启动Gunicorn3服务时出现以下错误?

时间:2020-04-06 04:52:21

标签: nginx flask ubuntu-18.04

我正在编写一个Web应用程序,允许用户将文件上传到Web服务器。我正在使用NGINX,Flask和Gunicorn3来实现这一目标,并且遇到了以下错误,我不知道如何调试。

ubuntu@ip-172-31-27-128:~/flaskapp/templates$ sudo service gunicorn3 start
ubuntu@ip-172-31-27-128:~/flaskapp/templates$ sudo service gunicorn3 status
● gunicorn3.service - Gunicorn service
   Loaded: loaded (/etc/systemd/system/gunicorn3.service; static; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-04-06 04:44:08 UTC; 1s ago
  Process: 10281 ExecStart=/usr/bin/gunicorn3 --workers 3 --bind unix:flaskapp.sock -m 007 app:app (code=exited, status= Main PID: 10281 (code=exited, status=1/FAILURE)

Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     self.stop()
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:   File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 393Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     time.sleep(0.1)
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:   File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 244Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     self.reap_workers()
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:   File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 524Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Apr 06 04:44:08 ip-172-31-27-128 systemd[1]: gunicorn3.service: Main process exited, code=exited, status=1/FAILURE
Apr 06 04:44:08 ip-172-31-27-128 systemd[1]: gunicorn3.service: Failed with result 'exit-code'.
lines 1-16/16 (END)...skipping...
● gunicorn3.service - Gunicorn service
   Loaded: loaded (/etc/systemd/system/gunicorn3.service; static; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2020-04-06 04:44:08 UTC; 1s ago
  Process: 10281 ExecStart=/usr/bin/gunicorn3 --workers 3 --bind unix:flaskapp.sock -m 007 app:app (code=exited, status=1/FAILURE)
 Main PID: 10281 (code=exited, status=1/FAILURE)

Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     self.stop()
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:   File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 393, in stop
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     time.sleep(0.1)
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:   File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 244, in handle_chld
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     self.reap_workers()
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:   File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 524, in reap_workers
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Apr 06 04:44:08 ip-172-31-27-128 gunicorn3[10281]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Apr 06 04:44:08 ip-172-31-27-128 systemd[1]: gunicorn3.service: Main process exited, code=exited, status=1/FAILURE
Apr 06 04:44:08 ip-172-31-27-128 systemd[1]: gunicorn3.service: Failed with result 'exit-code'.

独角兽服务

[Unit]
Description=Gunicorn service
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/flaskapp
ExecStart=/usr/bin/gunicorn3 --workers 3 --bind unix:flaskapp.sock -m 007 app:app

Flask应用代码:

import os
from flask import Flask, render_template#,request,url_for, redirect

app = Flask(__name__)

UPLOAD_FOLDER = '/home/RAW_Images'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

@app.route("/")
def home_func():
        return render_template("home.html")

@app.route("/handleUpload", method=['POST'])
def handleFileUpload():
        files = files.request.files.getlist("photo")
#       for file in files:
#               file.save(os.path.join(app.config['UPLOAD_FOLDER'], file.filename))
        return files.filename

如果我注释掉@app.route("/handleUpload", method=['POST']及其后续功能,则该服务可以正常启动。

我在做什么错?我真的很陌生。

谢谢。

0 个答案:

没有答案
相关问题