Search code examples
herokusinatraprocfile

"No Procfile detected" in Sinatra app heroku push


I am new with Sinatra and heroku. I am trying to push a small Sinatra app to heroku and I am getting this error,

 Bundle completed (24.34s)
   Cleaning up the bundler cache.
-----> WARNINGS:
       No Procfile detected, using the default web server (webrick)
       ##I have gone over the docs a few times and added unicorn 
       https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for Ruby  -> console, rake, web

-----> Compressing... done, 17.5MB
-----> Launching... done, v8

This is what my gem file looks like

   source 'https://rubygems.org'
   ruby '2.1.1'
   gem 'sinatra'
   gem 'sinatra-contrib'
   gem 'typhoeus'
   gem 'pry'
   gem 'rspec'
   gem 'pg'
   gem 'unicorn'
   gem 'thin', '1.2.7'

I have tried many things that I have seen online and This error still appears. Sorry if this is a silly question But its driving me nuts! If you would like to see anymore files in the app I will happily add them, I am just not to sure what ones to add..

Thank you for your time and I appreciate your help.


Solution

  • Procfile tells Heroku about different process types (commands) your application can run. For Ruby apps, Heroku expects you to declare at least one web process type, and also automatically initiates two additional processes by default: rake and console.

    This means that your Ruby app should be able to run a web process (this is the process that actually serves web pages and assets), run rake tasks, and provide you with a shell-like console (access it by running heroku run console in top-level of your app).

    All you need to do is add a blank text file called Procfile to the top level folder of your app, with just one line of code (if you're using Rack):

    web: bundle exec rackup config.ru -p $PORT
    

    Or if you're using pure Sinatra (without Rack):

    web: bundle exec ruby web.rb -p $PORT
    

    You should really read Define a Procfile and The Procfile in Heroku's dev center to clear up any confusion.