我正在尝试使用mod\fcgid和flup在服务器上部署apache2.4上的Flask应用程序。你知道吗
我的Flask应用程序是一个大Python3.6应用程序。 我把它注册为一项服务(机器人服务)并为Apache创建了一个虚拟主机配置。在重新启动apache和systemctl之后,我启动了我的机器人服务并询问其状态(sudo systemctl status bot)并获得以下错误消息:
May 31 11:18:06 vlg00086 systemd[1]: bot.service: Unit entered failed state.
May 31 11:18:06 vlg00086 systemd[1]: bot.service: Failed with result 'exit-code'.
May 31 11:18:06 vlg00086 systemd[1]: bot.service: Service RestartSec=100ms expired, scheduling restart.
May 31 11:18:06 vlg00086 systemd[1]: Stopped Chatbot_classification_system.
May 31 11:18:06 vlg00086 systemd[1]: bot.service: Start request repeated too quickly.
May 31 11:18:06 vlg00086 systemd[1]: Failed to start Chatbot_classification_system.
May 31 11:18:06 vlg00086 systemd[1]: bot.service: Unit entered failed state.
May 31 11:18:06 vlg00086 systemd[1]: bot.service: Failed with result 'start-limit'.
我的应用程序位于这里:/folder\u name/data\u folder/local\u html/Chatbot\u classification\u system/ 具有以下结构:
Chatbot_classification_system/
bot/
module1/…
module2/…
...
module…/…
templates/…
__init__.py
__main__.py
bot.fcgi
config.py
forms.py
… (other .py modules)
lib/…
templates/…
tests/…
wwww/
.htaccess
__init__.py
bot.service
bot_exe.sh
config.json
globals.py
requieremnts.txt
setup.py
它与pip一起安装在python3.6虚拟环境中。你知道吗
它可以在内置Flask localhost上运行
python3.6 __main__.py.
在执行一些特定于程序的步骤(创建用户id等)之后,应用程序将用户重定向到flask localhost并显示一个带有问题的html页面表单。你知道吗
我创造了一个机器人.fcgi文件。你知道吗
我不使用from bot.main.py import app语句,只需从主.py文件,因为前面还有许多附加步骤应用程序运行我不想迷失在进口中。你知道吗
#!/folder_name/data_folder/local_html/pythons/python3.6.3/bin/python3.6
import sys, os
print("1")
from flup.server.fcgi import WSGIServer
print("2")
import pandas as pd
import json
from flask import Flask, render_template, flash, request
from bot.forms import ReusableForm
import re
from werkzeug.datastructures import ImmutableMultiDict
# …
# (other imports)
print("test imports done...")
list_of_meta_labels = {...}
# (… programm specific code)
#--------------------------------------------------------------------------
# App configuration:
#--------------------------------------------------------------------------
app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = '...'
app.config['EXPLAIN_TEMPLATE_LOADING'] = True
print("app configured...")
# … (Programm specific code)
def submit(name):
# ...
def try_strip(inp):
# ...
def read_conf(): READ CONFIGURATION FILE # get Environment variables
# …
@app.route("/", methods=['GET', 'POST']) # URL to trigger our function
def support_form(test=None):
# … (programm specific steps)
form = ReusableForm(request.form)
# … (programm specific steps)
#------------------------------------------------------------------------
# Update "form" with the answer and send it the response page:
#------------------------------------------------------------------------
parameters = request.form.to_dict()
parameters['answer'] = answer_html
form = ImmutableMultiDict(parameters)
return render_template('success_landing_page.html', title='Index',
form=form)
if __name__ == '__main__':
app.debug = True
WSGIServer(app).run()
[Unit]
Description=Chatbot_classification_system
[Service]
ExecStart= /folder_name/data_folder/local_html/Chatbot_classification_system/bot/bot.fcgi
Restart=always
Group=dlm_nagios
Environment=NODE_ENV=production
WorkingDirectory /folder_name/data_folder/Chatbot_classification_system/
[Install]
WantedBy=multi-user.target
/etc/apache2/vhosts.d/50006.conf文件:
LoadModule fcgid_module ./usr/lib64/apache2/mod_fcgid.so
<VirtualHost *:50006>
ServerRoot /folder_name/data_folder/local_html/Chatbot_classification_system
DocumentRoot /folder_name/data_folder/local_html/Chatbot_classification_system/templates
AddHandler fcgid-script .fcgi
ScriptAlias / /folder_name/data_folder/local_html/Chatbot_classification_system/bot/bot.fcgi/
<Location />
SetHandler fcgid-script
</Location>
</VirtualHost>
我重启一切:
service httpd restart
sudo systemctl daemon-reload
sudo systemctl start bot
的输出
sudo systemctl status bot
是
* bot.service - Chatbot_classification_system
Loaded: loaded (/etc/systemd/system/bot.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Fri 2019-05-31 12:13:59 UTC; 29min ago
Process: 20899 ExecStart=/folder_name/data_folder/local_html/Chatbot_classification_system/bot.fcgi (code=exited, status=203/EXEC)
Main PID: 20899 (code=exited, status=203/EXEC)
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Main process exited, code=exited, status=203/EXEC
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Unit entered failed state.
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Failed with result 'exit-code'.
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Service RestartSec=100ms expired, scheduling restart.
May 31 12:13:59 vlg00086 systemd[1]: Stopped Chatbot_classification_system.
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Start request repeated too quickly.
May 31 12:13:59 vlg00086 systemd[1]: Failed to start Chatbot_classification_system.
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Unit entered failed state.
May 31 12:13:59 vlg00086 systemd[1]: bot.service: Failed with result 'start-limit'.
的输出
sudo apache2ctl -S
是
VirtualHost configuration:
*:50006 server_name.sss.sss.corp (<it is our Server name>) (/etc/apache2/vhosts.d/50006.conf:3)
ServerRoot: "/folder_name/data_folder/local_html/Chatbot_classification_system"
Main DocumentRoot: "/folder_name/data_folder/local_html/Chatbot_classification_system"
Main ErrorLog: "/var/log/apache2/error_log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex fcgid-pipe: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/httpd.pid"
Define: SYSCONFIG
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="wwwrun" id=30
Group: name="www" id=8
我试着用
§ python3.6 bot.fcgi
当然,这样应用程序不会获得任何服务器配置信息,但它允许检查代码本身是否启动时没有错误。你知道吗
我看到“1”、“2”、“测试导入完成…”和“应用程序配置…”打印语句和以下消息:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 301 MOVED PERMANENTLY
Content-Type: text/html; charset=utf-8
Content-Length: 241
Location: http://localhost/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="http://localhost/">http://localhost/</a>. If not click the link.
我猜这意味着程序启动时没有错误,然后找不到服务器配置(这是正常的,因为它在apache中),并显示404错误消息。 似乎问题出在我的Apache配置中的某个地方。你知道吗
如果有人能帮我,我会很高兴的!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐