Я пишу веб-приложение, которое позволяет пользователям загружать файлы на веб-сервер. Я использую 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'.
служба gunicorn
[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']
и его последующую функцию, то служба будет работать нормально.
Что я делаю не так? Я действительно новичок в этом.
Спасибо.