3

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.

Spinne
  • 65
  • 1
  • 5
  • Yeah. Then I have to stop all manually. – Spinne Jul 03 '19 at 06:33
  • I'm not sure where the older comment went, but processes don't "keep running" after a deploy on Heroku. Deploying creates brand new application slugs and replaces the old ones with the new ones. There's something else going on here. – ChrisGPT was on strike Jul 03 '19 at 12:36

1 Answers1

1

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
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • This isn't going to auto start my app. I only can see this dyno in the "resources" tab. – Spinne Jul 03 '19 at 06:28
  • "This isn't going to auto start my app"—It defines processes. If you have a single `web` process, for example, it will normally start it as well, though you may have to scale up your dynos (this is manual since it can cost you money). 'I only can see this dyno in the "resources" tab'—seeing a dyno means something is running. _What do you expect to see instead?_ You're going to have to be more clear about what the problem is if you expect to get help here. Please read [ask]. – ChrisGPT was on strike Jul 03 '19 at 12:35