我是新手,所以请耐心等待
我正在尝试使用带有开放端口的AWS Ubuntu机器部署一个烧瓶应用程序 443 和 80
当我使用sudo python app.py
运行烧瓶应用时,它可以工作。
当我尝试使用gunicorn
时出现问题。当我使用命令
gunicorn -b 0.0.0.0:443 app:app
它推动了这个错误
[2018-06-18 13:30:30 +0000] [11135] [INFO] Starting gunicorn 19.8.1
[2018-06-18 13:30:30 +0000] [11135] [ERROR] Retrying in 1 second.
[2018-06-18 13:30:31 +0000] [11135] [ERROR] Retrying in 1 second.
[2018-06-18 13:30:32 +0000] [11135] [ERROR] Retrying in 1 second.
[2018-06-18 13:30:33 +0000] [11135] [ERROR] Retrying in 1 second.
[2018-06-18 13:30:34 +0000] [11135] [ERROR] Retrying in 1 second.
[2018-06-18 13:30:35 +0000] [11135] [ERROR] Can't connect to ('0.0.0.0', 443)
我已检查过没有进程使用lsof -i:443
这是app.py
from flask import Flask
application = Flask(__name__)
@application.route("/")
def index():
return "Hello World!"
if __name__ == "__main__":
application.run(host='0.0.0.0', port='443')
已修改:使用sudo -H pip install gunicorn
我正在尝试在生产中部署应用程序,因此我希望它能够持续运行。我尝试supervisor
一直保持
以下是supervisor
[program:app_name]
directory=/home/ubuntu/FIFA_Captcha
command=/usr/local/bin/gunicorn -b 0.0.0.0:443 app:app
autostart=true
user=root
autorestart=true
stderr_logfile=/home/ubuntu/app_name.err.log
stdout_logfile=/home/ubuntu/app_name.out.log
environment=PYTHONPATH=/usr/bin/python
输出sudo service supervisor status
Jun 18 22:02:39 ip-172-31-3-59 systemd[1]: Started Supervisor process control system for UNIX.
Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,828 CRIT Supervisor running as root (no user in config file)
Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,829 WARN Included extra file "/etc/supervisor/conf.d/app_name.conf" Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,834 INFO RPC interface 'supervisor' initialized
Jun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,834 CRIT Server 'unix_http_server' running without any HTTP authenticatJun 18 22:02:39 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:39,834 INFO supervisord started with pid 19562
Jun 18 22:02:40 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:40,837 INFO spawned: 'app_name' with pid 19569
Jun 18 22:02:40 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:40,952 INFO exited: app_name(exit status 3; not expected)
Jun 18 22:02:41 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:41,955 INFO spawned: 'app_name' with pid 19574
Jun 18 22:02:42 ip-172-31-3-59 supervisord[19562]: 2018-06-18 22:02:42,069 INFO exited: app_name(exit status 3; not expected)
app_name.err.log
的输出。虽然我设置了PYTHONPATH
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
File "/home/ubuntu/FIFA_Captcha/app.py", line 2, in <module>
from flask import Flask, render_template, request
ImportError: No module named flask
[2018-06-18 22:09:34 +0000] [19681] [INFO] Worker exiting (pid: 19681)
[2018-06-18 22:09:34 +0000] [19677] [INFO] Shutting down: Master
[2018-06-18 22:09:34 +0000] [19677] [INFO] Reason: Worker failed to boot.
答案 0 :(得分:1)
您需要root才能使用端口443。