I have made a bot in Java and it works great when I run the command:
heroku run nohup java -jar bot.jar
However, after 24h Heroku closes it because of their Dyno policy. So, I thought of making a Procfile in order for it to execute the command above everytime it comes alive again.
I've tried placing the following commands inside the Procfile:
worker: java -jar bot.jar
worker: nohup java -jar bot.jar
And I even made a run.sh file that contains:
#!/bin/bash
nohup java -jar bot.jar
In order to make a Procfile that has:
worker: sh run.sh
Sadly, none of this works, because everytime the Dyno executes the Procfile (right after I push a new version of it through git), the bot never comes alive. The logs show:
2017-06-07T13:17:33.651806+00:00 app[api]: Starting process with command `sh run.sh` by XXXX
2017-06-07T13:17:37.958327+00:00 heroku[run.2087]: State changed from starting to up
2017-06-07T13:17:37.948696+00:00 heroku[run.2087]: Awaiting client
2017-06-07T13:17:38.283581+00:00 heroku[run.2087]: Starting process with command `sh run.sh`
2017-06-07T13:17:52.807189+00:00 heroku[run.2087]: Client connection closed. Sending SIGHUP to all processes
2017-06-07T13:17:53.343009+00:00 heroku[run.2087]: Process exited with status 129
2017-06-07T13:17:53.359331+00:00 heroku[run.2087]: State changed from up to complete
2017-06-07T13:24:32.000000+00:00 app[api]: Build started by user XXXX
2017-06-07T13:24:43.090567+00:00 app[api]: Deploy YYYY by user XXXX
2017-06-07T13:24:43.090567+00:00 app[api]: Release v17 created by user XXXX
2017-06-07T13:24:32.000000+00:00 app[api]: Build succeeded
I have no idea what to do in order for my bot to run from the Procfile. Can you help me?
Thanks.
Try running:
$ heroku ps:scale worker=1
This will ensure that one worker process is always running.