简体   繁体   English

Heroku - 没有正在运行的Web进程

[英]Heroku - No web process running

I made a twitter bot using tweepy in Python and tried deploying it using Heroku. 我在Python中使用tweepy创建了一个twitter机器人,并尝试使用Heroku进行部署。 The Bot just tweets after certain intervals. Bot只是在一定间隔后发推文。 After deploying it, the Python program just doesn't run and Heroku log shows the following error : 部署之后,Python程序就不运行了,Heroku日志显示以下错误:

at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=fathomless-island-25537.herokuapp.com request_id=0aa76d12-31e6-4940-85ec-a8476af4f82f fwd="182.64.210.145" dyno= connect= service= status=503 bytes=

After looking through some similar problems where a django app has to be deployed, I tried: 在查看了必须部署django应用程序的类似问题之后,我尝试了:

heroku ps:scale web=1

and got: 得到了:

Scaling dynos... !
 !  Couldn't find that formation.

Does it mean that the program failed to establish a web process or is there something else related to dynos ? 这是否意味着该程序未能建立网络流程或是否存在与dynos相关的其他内容? Or if I have to include some code related to dynos in my program ? 或者,如果我必须在我的程序中包含一些与dynos相关的代码? I don't know which part of this whole process has a problem. 我不知道整个过程的哪个部分有问题。 Apologies if it's too basic. 道歉,如果它太基础了。

The question is a bit older, but anyway... 问题有点老了,但无论如何......

Before you can scale the dynos, you need to have a Procfile, where you define what should happen when the process is started. 在缩放dynos之前,您需要有一个Procfile,您可以在其中定义启动进程时应该发生的事情。 In your case the process should be called web . 在您的情况下,该过程应称为web We'll come the the content of the file in a moment. 我们马上就会看到文件的内容。

But first: To me it seems best to use gunicorn for running python apps on heroku, so first you should install gunicorn, run pip freeze > requirements.txt and push it to heroku (well, wait with that until you have the Procfile). 但首先:对我而言,最好使用gunicorn在heroku上运行python应用程序,所以首先你应该安装gunicorn,运行pip freeze > requirements.txt并将其推送到heroku(好吧,等到你拥有Procfile)。 For more see: python with gunicorn on heroku 有关更多信息,请参阅: heroku上带有gunicorn的python

The Procfile only needs one line web: gunicorn <filename>:<main method name> . Procfile只需要一行web: gunicorn <filename>:<main method name> In your case this would be (assuming your main method is called 'app') web: gunicorn bot:app . 在你的情况下,这将是(假设你的主要方法被称为'app') web: gunicorn bot:app

Now push all that to heroku, then you can scale your dyno with the command you used heroku ps:scale web=1 现在将所有内容推送到heroku,然后你可以使用你使用heroku ps:scale web=1的命令来缩放你的dyno

When you try heroku ps:scale web=1 and everything else in vain, check that you have Procfile with correct name and content. 当你尝试heroku ps:scale web=1和其他一切都是徒劳的时候,检查你的Procfile是否有正确的名称和内容。 I had a problem with it. 我遇到了问题。 After fixing the name and content, and pushing the update to heroku, the app started by itself. 修复名称和内容,并将更新推送到heroku后,应用程序自行启动。 After that heroku open works as expected. 之后, heroku open按预期工作。

I was having trouble getting my app to load, until I modified my Procfile 我无法加载我的应用程序,直到我修改了我的Procfile

from saying 从说

web: gunicorn app:app

to

web gunicorn app:app

Removing the : after web made it work for me. 删除:web之后使它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM