0

I have a Gradle program that runs a Discord bot on Heroku. The bot handles all possible exceptions, and it runs beautifully on my PC. I switched to Heroku, because I do not want the bot to go offline when I need to restart my PC or for other reasons.

According to the app's logs, the program has no errors. A few minutes after deployment, the logs simply say "State changed from starting to crashed." Is there a way to get more details about why the app crashed? I'm 90% convinced my app does not crash on its own, as it has been running on my PC for quite some time with no problems.

Every once in a while, the logs will say "State changed from crashed to starting" and the program will rerun as if I redeployed the app, but I did not. Could Heroku be cycling the app in some way?

Either way, the app only runs for around two to five minutes, never longer, with no errors in the logs. Any help is appreciated!

Spencer Cain
  • 63
  • 1
  • 10
  • Does your Discord bot deploy a web page? Do you need to use a port? Does it say something along the lines of `Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch`? – Tin Nguyen Apr 06 '20 at 17:08
  • Yes, I got Error R10 except it was 90 seconds of launch since Java processes take longer to boot. However, I used the boot time tool to increase boot time to 180 seconds. Also, no there is no web page. I'm not sure what a port would be used for but I used -Dserver.port=$PORT in the Procfile. – Spencer Cain Apr 06 '20 at 21:58
  • I installed a logger to the application called Timber.io. While I get the logs an hour after it happens, that is where Error R10 shows up. – Spencer Cain Apr 06 '20 at 22:00
  • In your `Procfile` change first word ´web` to `worker`. – Tin Nguyen Apr 07 '20 at 07:05

1 Answers1

2

With no front end for my bot, it is not necessary to use web: in the Procfile, as I did not fully understand from the Getting Started tutorial. Instead use worker: for apps with only back end processes. Also, from the CLI, verify that there are no web processes with

heroku ps:scale --app <app-name> web=0

and set up a back end process with

heroku ps:scale --app <app-name> worker=1

or more if necessary. Also, avoid flags for attaching to a port in the Procfile if you have no front end.

To learn more about why this causes issues if not right, visit https://devcenter.heroku.com/articles/dynos#dyno-configurations

Shoutout to VxJasonxV for the help.

Spencer Cain
  • 63
  • 1
  • 10