Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: How to auto start Python app on deploy?

I've got a Heroku app which automatically deploys when I'm pushing changes to GitHub. It's a Discord Bot (written in python).

Now I want to automatically start this python script when I'm going to deploy (It should run 24/7 until it's stopped by a new deploy).

I read about Dynos but don't know how to use them. I already added the Procfile with bot: python bot.py but this won't auto start the app. The Dyno is only shown in the resources tab on the dashboard. Using heroku ps -a myapp it responds with No dynos on ⬢ myapp. The bot: python bot.py Dyno in the dashboard also can't be started through that switch.

Screenshot: The switch can't be activated

So I tried to use release: python bot.py which starts the bot but after another deploy the processes are stacking up and the bot is running multiple times.

like image 797
Spinne Avatar asked Feb 20 '26 11:02

Spinne


1 Answers

Don't use a release command for this.

release commands run once as part of the deploy, then they're done. Your application should probably be set up as a web process (if it's supposed to respond to HTTP requests):

web: python myapp.py

or a worker process (if it isn't):

worker: python myapp.py
like image 96
Chris Avatar answered Feb 21 '26 23:02

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!