Heroku [=h10=] 成功后出现错误 运行 heroku container:push web 和 heroku container:release web
Heroku "Missing required flag -a --app" error after succesfully running heroku container:push web and heroku container:release web
我有一个 Docker 容器,我正尝试将其部署为 Heroku 应用程序。我的应用程序名为
morning-bayou-58742
之前我运行成功执行了以下命令
heroku container:login
heroku create
heroku container:push web --app morning-bayou-58742
heroku container:release web --app morning-bayou-58742
后者的输出为
Releasing images web to morning-bayou-58742... done
然而,当我打开我的网络应用程序时,出现以下错误
Application error
An error occurred in the application and your page could not be
served. If you are the application owner, check your logs for details.
You can do this from the Heroku CLI with the command heroku logs
--tail
当我检查日志尾部时,我得到以下内容
heroku logs --tail
» Error: Missing required flag: » -a, --app APP app to run
command against » See more help with --help
现在我尝试做的是尝试 运行 来自 Heroku https://devcenter.heroku.com/articles/container-registry-and-runtime#getting-started 的入门文档,它是这样的:
heroku container:login
git clone https://github.com/heroku/alpinehelloworld.git
heroku create
heroku container:push web
heroku container:release web
heroku open
而且效果很好!所以我现在更糊涂了。你能提供一些关于问题可能是什么的提示吗?以防万一,这是我的 Docker 容器结构,当我 运行 使用 localhost:
时它工作正常
app.py:
#my libraries
import pickle
import numpy as np
import sys
import os
from sklearn.neighbors import KNeighborsClassifier
from flask import Flask, request
#set port
port = int(os.environ.get("PORT", 5000))
#open model back
with open('./model.pkl', 'rb') as model_pkl:
knn = pickle.load(model_pkl)
knn.n_jobs=1
#flask application
app = Flask(__name__)
#API endpoint
@app.route('/predict')
def predict_iris():
#retrieve parameters
sl = float(request.args.get('sl'))
sw = float(request.args.get('sw'))
pl = float(request.args.get('pl'))
pw = float(request.args.get('pw'))
#predict result
new_record = np.array([[sl, sw, pl, pw]])
print(new_record)
predict_result = knn.predict(new_record)[0]
#label classes
classes=['setosa', 'versicolor', 'virginica']
#encode result
if predict_result==0:
result=classes[0]
elif predict_result==1:
result=classes[1]
elif predict_result==2:
result=classes[2]
else:
print("nothing to show")
#return result
return "Prediction is: " + str(result)
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0',port=port)
Docker文件:
FROM python:3.5.3
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT python ./app.py
Requirements.txt:
numpy==1.13
scipy==0.19.1
Flask==0.12.2
scikit-learn==0.18.1
我的 Docker 容器称为 flask-heroku-bis
,我 运行 使用命令
docker run -d -p 5000:5000 flask-heroku-bis
然后我在输入本地 url 调用时得到结果,例如 http://localhost:5000/predict?sl=100.2&sw=11.7&pl=10.8&pw=3
我认为问题可能与此调用的结构有关,但我不是 100% 确定。
感谢任何帮助!
编辑:
这是日志详细信息:
heroku logs --tail -a morning-bayou-58742
2021-05-29T22:29:14.397676+00:00 app[api]: Release v1 created by user acr@ciencias.unam.mx
2021-05-29T22:29:14.397676+00:00 app[api]: Initial release by user acr@ciencias.unam.mx
2021-05-29T22:29:14.608281+00:00 app[api]: Enable Logplex by user acr@ciencias.unam.mx
2021-05-29T22:29:14.608281+00:00 app[api]: Release v2 created by user acr@ciencias.unam.mx
2021-05-29T22:48:10.986325+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=22a535c8-7762-41a2-b41a-d6d7b284dba2 fwd="187.145.160.213" dyno= connect= service= status=502 bytes= protocol=https
2021-05-29T22:48:11.914173+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=morning-bayou-58742.herokuapp.com request_id=60baae74-e461-4503-9707-b14455e5b659 fwd="187.145.160.213" dyno= connect= service= status=502 bytes= protocol=https
2021-05-29T23:13:14.880739+00:00 app[api]: Deployed web (ec731afa5e23) by user acr@ciencias.unam.mx
2021-05-29T23:13:14.880739+00:00 app[api]: Release v3 created by user acr@ciencias.unam.mx
2021-05-29T23:13:14.895055+00:00 app[api]: Scaled to web@1:Free by user acr@ciencias.unam.mx
2021-05-29T23:13:34.012193+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-29T23:13:36.661935+00:00 heroku[web.1]: Process exited with status 0
2021-05-29T23:13:36.715749+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-29T23:13:36.731837+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-29T23:14:07.678289+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-29T23:14:10.298318+00:00 heroku[web.1]: Process exited with status 0
2021-05-29T23:14:10.379011+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-29T23:17:25.175836+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=bfc884bc-2126-4c11-97f8-93685f427829 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-29T23:18:27.556876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=1.2&sw=1.3&pl=2.2&pw=2.5" host=morning-bayou-58742.herokuapp.com request_id=ee53e591-8073-43a0-b11f-96f7e0c45d3f fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-29T23:27:11.115330+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=7546a2d3-303f-41f0-b088-8e91efa73056 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-29T23:40:18.663684+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-29T23:40:38.521811+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-29T23:40:42.122447+00:00 heroku[web.1]: Process exited with status 0
2021-05-29T23:40:42.188076+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-29T23:48:59.865089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="//predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=10154798-1a4a-40ca-998a-f7ee4d246f01 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:41:44.486049+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="//predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=b9144b62-50a3-47cb-9c68-c603325d3fd5 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:41:52.067158+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=81eb9141-ac91-4d0d-a5ed-effcbd38a5c3 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:41:57.056831+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=10.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=44b3cb17-9d78-49cf-85d6-1cc3c322faf3 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:42:06.449665+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=f06a1b78-869e-49a4-8d49-35c9c818d58d fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:49:28.827777+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=4554ee2a-535d-4065-b918-c79b3fa3842d fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:49:37.654869+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=7aa83238-3fc4-4008-869a-1c5e63800a94 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:50:02.630469+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=155dad59-5ed6-4566-8256-dabe4f844575 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T01:06:53.316983+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-30T01:07:14.003209+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-30T01:07:17.213751+00:00 heroku[web.1]: Process exited with status 0
2021-05-30T01:07:17.284112+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-30T02:50:08.542836+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-30T02:50:28.877273+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-30T02:50:31.667687+00:00 heroku[web.1]: Process exited with status 0
2021-05-30T02:50:31.734689+00:00 heroku[web.1]: State changed from starting to crashed
由于您没有详细的日志文件,这里很难排除故障。您可以先尝试执行此操作以查明确切的问题:
heroku logs --tail -a morning-bayou-58742
接下来,尝试使用命令 heroku open
访问您已部署的应用程序,以防万一 url.
有任何拼写错误
编辑:
由于 Heroku 中的网络限制,Dockerfile 中的 EXPOSE
不受支持,Heroku 需要 CMD
才能 运行 容器。基于 Flask 的示例应用程序可以这样启动 (reference):
FROM python:3.5.3
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
# Expose is NOT supported by Heroku
# EXPOSE 5000
# Run the app. CMD is required to run on Heroku
# $PORT is set by Heroku
CMD gunicorn --bind 0.0.0.0:$PORT wsgi
我有一个 Docker 容器,我正尝试将其部署为 Heroku 应用程序。我的应用程序名为
morning-bayou-58742
之前我运行成功执行了以下命令
heroku container:login
heroku create
heroku container:push web --app morning-bayou-58742
heroku container:release web --app morning-bayou-58742
后者的输出为
Releasing images web to morning-bayou-58742... done
然而,当我打开我的网络应用程序时,出现以下错误
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail
当我检查日志尾部时,我得到以下内容
heroku logs --tail
» Error: Missing required flag: » -a, --app APP app to run command against » See more help with --help
现在我尝试做的是尝试 运行 来自 Heroku https://devcenter.heroku.com/articles/container-registry-and-runtime#getting-started 的入门文档,它是这样的:
heroku container:login
git clone https://github.com/heroku/alpinehelloworld.git
heroku create
heroku container:push web
heroku container:release web
heroku open
而且效果很好!所以我现在更糊涂了。你能提供一些关于问题可能是什么的提示吗?以防万一,这是我的 Docker 容器结构,当我 运行 使用 localhost:
时它工作正常app.py:
#my libraries
import pickle
import numpy as np
import sys
import os
from sklearn.neighbors import KNeighborsClassifier
from flask import Flask, request
#set port
port = int(os.environ.get("PORT", 5000))
#open model back
with open('./model.pkl', 'rb') as model_pkl:
knn = pickle.load(model_pkl)
knn.n_jobs=1
#flask application
app = Flask(__name__)
#API endpoint
@app.route('/predict')
def predict_iris():
#retrieve parameters
sl = float(request.args.get('sl'))
sw = float(request.args.get('sw'))
pl = float(request.args.get('pl'))
pw = float(request.args.get('pw'))
#predict result
new_record = np.array([[sl, sw, pl, pw]])
print(new_record)
predict_result = knn.predict(new_record)[0]
#label classes
classes=['setosa', 'versicolor', 'virginica']
#encode result
if predict_result==0:
result=classes[0]
elif predict_result==1:
result=classes[1]
elif predict_result==2:
result=classes[2]
else:
print("nothing to show")
#return result
return "Prediction is: " + str(result)
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0',port=port)
Docker文件:
FROM python:3.5.3
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT python ./app.py
Requirements.txt:
numpy==1.13
scipy==0.19.1
Flask==0.12.2
scikit-learn==0.18.1
我的 Docker 容器称为 flask-heroku-bis
,我 运行 使用命令
docker run -d -p 5000:5000 flask-heroku-bis
然后我在输入本地 url 调用时得到结果,例如 http://localhost:5000/predict?sl=100.2&sw=11.7&pl=10.8&pw=3
我认为问题可能与此调用的结构有关,但我不是 100% 确定。
感谢任何帮助!
编辑: 这是日志详细信息:
heroku logs --tail -a morning-bayou-58742
2021-05-29T22:29:14.397676+00:00 app[api]: Release v1 created by user acr@ciencias.unam.mx
2021-05-29T22:29:14.397676+00:00 app[api]: Initial release by user acr@ciencias.unam.mx
2021-05-29T22:29:14.608281+00:00 app[api]: Enable Logplex by user acr@ciencias.unam.mx
2021-05-29T22:29:14.608281+00:00 app[api]: Release v2 created by user acr@ciencias.unam.mx
2021-05-29T22:48:10.986325+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=22a535c8-7762-41a2-b41a-d6d7b284dba2 fwd="187.145.160.213" dyno= connect= service= status=502 bytes= protocol=https
2021-05-29T22:48:11.914173+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=morning-bayou-58742.herokuapp.com request_id=60baae74-e461-4503-9707-b14455e5b659 fwd="187.145.160.213" dyno= connect= service= status=502 bytes= protocol=https
2021-05-29T23:13:14.880739+00:00 app[api]: Deployed web (ec731afa5e23) by user acr@ciencias.unam.mx
2021-05-29T23:13:14.880739+00:00 app[api]: Release v3 created by user acr@ciencias.unam.mx
2021-05-29T23:13:14.895055+00:00 app[api]: Scaled to web@1:Free by user acr@ciencias.unam.mx
2021-05-29T23:13:34.012193+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-29T23:13:36.661935+00:00 heroku[web.1]: Process exited with status 0
2021-05-29T23:13:36.715749+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-29T23:13:36.731837+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-29T23:14:07.678289+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-29T23:14:10.298318+00:00 heroku[web.1]: Process exited with status 0
2021-05-29T23:14:10.379011+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-29T23:17:25.175836+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=bfc884bc-2126-4c11-97f8-93685f427829 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-29T23:18:27.556876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=1.2&sw=1.3&pl=2.2&pw=2.5" host=morning-bayou-58742.herokuapp.com request_id=ee53e591-8073-43a0-b11f-96f7e0c45d3f fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-29T23:27:11.115330+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=7546a2d3-303f-41f0-b088-8e91efa73056 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-29T23:40:18.663684+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-29T23:40:38.521811+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-29T23:40:42.122447+00:00 heroku[web.1]: Process exited with status 0
2021-05-29T23:40:42.188076+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-29T23:48:59.865089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="//predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=10154798-1a4a-40ca-998a-f7ee4d246f01 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:41:44.486049+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="//predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=b9144b62-50a3-47cb-9c68-c603325d3fd5 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:41:52.067158+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=81eb9141-ac91-4d0d-a5ed-effcbd38a5c3 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:41:57.056831+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=10.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=44b3cb17-9d78-49cf-85d6-1cc3c322faf3 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:42:06.449665+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=f06a1b78-869e-49a4-8d49-35c9c818d58d fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:49:28.827777+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=4554ee2a-535d-4065-b918-c79b3fa3842d fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:49:37.654869+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-bayou-58742.herokuapp.com request_id=7aa83238-3fc4-4008-869a-1c5e63800a94 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T00:50:02.630469+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/predict?sl=100.2&sw=11.7&pl=10.8&pw=3" host=morning-bayou-58742.herokuapp.com request_id=155dad59-5ed6-4566-8256-dabe4f844575 fwd="187.145.160.213" dyno= connect= service= status=503 bytes= protocol=https
2021-05-30T01:06:53.316983+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-30T01:07:14.003209+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-30T01:07:17.213751+00:00 heroku[web.1]: Process exited with status 0
2021-05-30T01:07:17.284112+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-30T02:50:08.542836+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-30T02:50:28.877273+00:00 heroku[web.1]: Starting process with command `/bin/sh -c python\ ./app.py`
2021-05-30T02:50:31.667687+00:00 heroku[web.1]: Process exited with status 0
2021-05-30T02:50:31.734689+00:00 heroku[web.1]: State changed from starting to crashed
由于您没有详细的日志文件,这里很难排除故障。您可以先尝试执行此操作以查明确切的问题:
heroku logs --tail -a morning-bayou-58742
接下来,尝试使用命令 heroku open
访问您已部署的应用程序,以防万一 url.
编辑:
由于 Heroku 中的网络限制,Dockerfile 中的 EXPOSE
不受支持,Heroku 需要 CMD
才能 运行 容器。基于 Flask 的示例应用程序可以这样启动 (reference):
FROM python:3.5.3
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
# Expose is NOT supported by Heroku
# EXPOSE 5000
# Run the app. CMD is required to run on Heroku
# $PORT is set by Heroku
CMD gunicorn --bind 0.0.0.0:$PORT wsgi