I’m getting ready to officially release my gradebook app, Participation. To take my app to the next level, I thought I would add some of the cool badges you see on GitHub READMEs advertising the app’s build and code coverage.
I had recently used Codeship and Coveralls on the team project for Firehose, so I decided to deploy to Heroku via Codeship again. But when I set up the pipeline to Heroku, my app exploded. Or, it crashed.
I ran the error over and over again, combing through the logs for clues. The most relevant error read:
2016-12-31T03:34:35.912642+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
The Heroku docs told me that Error R10 meant that my app was taking too long to deploy, and several Stack Overflow posts suggested gems that would allow my app longer than the allotted 60 seconds to deploy. But my app wasn’t too complicated — it shouldn’t need over 60 seconds to deploy.
To no avail, I followed the myriad of suggestions online: I restarted Heroku, migrated my database, and compiled my assets. But nothing worked!
It turned out that the business about
$PORT was most relevant. When I set up mailers with Devise, I had added a line of code in my Procfile:
web: bundle exec rails s. But my dynos on Heroku needed more instruction, specifically about the port.
When I changed the first line of my Procfile to
web: bundle exec rails s -p $PORT, my app seamlessly deployed to Heroku and everything was fixed!
It was difficult to unearth this solution on Google, so I wanted to document it for future confused programmers.
Bonus story: I also integrated Coveralls with my app, but the badge wouldn’t update on my GitHub ReadMe (and the pretty badge displaying my outstanding code coverage was obviously what it was all about). I switched to CodeCov, which was incredibly easy to figure out and also said that 99% of my code was covered (as opposed to Coveralls’ 94% estimate). I’m happy with the switch!