[英]Heroku successfully deployed but I still keep getting no web process running
I'm trying to push a telegram bot into Heroku.我正在尝试将电报机器人推送到 Heroku。 These are files within my folder.这些是我文件夹中的文件。
/new_bot
---/requirements.txt
---/Procfile #worker: python new_bot.py
---/init.py #empty
---/new_bot.py
---/.env
My procfile does NOT have any .txt extension.我的 procfile 没有任何 .txt 扩展名。 Inside the procfile is worker: python new_bot.py
I am using atom text editor. procfile 里面是worker: python new_bot.py
我正在使用 atom 文本编辑器。
In my requirements .txt folder, these are the following requirements在我的需求 .txt 文件夹中,这些是以下需求
requests
telegram
tornado>=5.1
The new_bot.py script is here new_bot.py 脚本在这里
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler, CallbackContext
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
import requests
PORT = int(os.environ.get('PORT', 443))
TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
def hello(update, context):
update.message.reply_text('Hello! \U0001F600')
def main():
updater = Updater(TOKEN, use_context=True)
dp = updater.dispatcher
dp.add_handler(CommandHandler("hello", hello))
updater.start_webhook(listen="0.0.0.0",
port=int(PORT),
url_path=TOKEN,
webhook_url='https://abc.herokuapp.com/' + TOKEN)
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
So it managed to build successfully, and I ran and did heroku ps:scale worker=1
in my heroku CLI, managed to deploy it successfully which showed this:所以它成功构建,我在我的 heroku CLI 中运行并执行heroku ps:scale worker=1
,成功部署它,显示了这一点:
2021-07-15T11:56:11.022397+00:00 heroku[worker.1]: State changed from crashed to starting
2021-07-15T11:56:15.944190+00:00 heroku[worker.1]: Starting process with command `python new_bot.py`
2021-07-15T11:56:17.093075+00:00 heroku[worker.1]: State changed from starting to up
2021-07-15T11:56:21.000000+00:00 app[api]: Build succeeded
2021-07-15T11:56:22.155897+00:00 app[worker.1]: 2.26.0
On my Heroku UI, I am seeing this在我的 Heroku UI 上,我看到了这个
worker
python new_bot.py
ON
However, I still keep getting this error at=error code=H14 desc="No web processes running" method=GET
.但是,我仍然不断收到此错误at=error code=H14 desc="No web processes running" method=GET
。 I have seen many places in Stackoverflow that I have to use heroku ps:scale web=1
, which is different from the command I used earlier which was heroku ps:scale worker=1
.我在 Stackoverflow 中看到很多地方必须使用heroku ps:scale web=1
,这与我之前使用的命令heroku ps:scale worker=1
。 Can I just check what am I doing wrong here and how do I remedy it?我可以检查一下我在这里做错了什么以及如何补救吗? Any help will be appreciated.任何帮助将不胜感激。
Edit: Hi guys I've actually found the problem already.编辑:嗨,伙计们,我实际上已经发现了问题。 It has to do with它与
updater.start_webhook(listen="0.0.0.0",
port=int(PORT),
url_path=TOKEN,
webhook_url='https://abc.herokuapp.com/' + TOKEN)
Thanks for helping anyway!无论如何感谢您的帮助!
For a web process in heroku you need to add something like this to your Proc file:对于 heroku 中的 Web 进程,您需要在 Proc 文件中添加如下内容:
Below is a rails equivalent, you need specific to your app.下面是一个 rails 等效项,您需要特定于您的应用程序。
web: bundle exec rails server -p $PORT
And then run:然后运行:
heroku ps:scale web=1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.