Heroku successfully deployed but I still keep getting no web process running

Viewed 160

I'm trying to push a telegram bot into 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. Inside the procfile is worker: python new_bot.py I am using atom text editor.

In my requirements .txt folder, these are the following requirements

requests
telegram
tornado>=5.1

The new_bot.py script is here

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:

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

worker
python new_bot.py
ON

However, I still keep getting this error 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. 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!

1 Answers

For a web process in heroku you need to add something like this to your Proc file:

Below is a rails equivalent, you need specific to your app.

web: bundle exec rails server -p $PORT

And then run:

heroku ps:scale web=1
Related