Heroku Cedar: how to stop using WEBrick - heroku

In my Gemfile I have:
gem 'thin'
But when I push my application to Heroku Cedar, WEBrick is still used ("Booting WEBrick" in logs).
Where might be a problem?

You just need to create a Procfile and add the following line:
web: bundle exec rails server -p $PORT thin -e $RACK_ENV
Push that to Heroku and you'll be all set.

Related

heroku bundler: failed to load command: rackup

I'm trying to deploy to heroku a modular sinatra app that works fine locally. This is in the heroku logs:
2020-12-28T21:05:15.907560+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 58645`
2020-12-28T21:05:18.738254+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.7.0/bin/rackup)
2020-12-28T21:05:18.738283+00:00 app[web.1]: Gem::Exception: can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
The command bundle exec rackup config.ru -p 58645 runs fine locally.
This is my config.ru
require_relative './config/environment.rb'
use EntreeController
use UserController
run ApplicationController
and environment.rb
APP_ENV = ENV["RACK_ENV"] || "development"
ENV['SINATRA_ENV'] ||= "development"
require 'require_all'
require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])
require_all 'app'
require_all 'app/models'
require_all 'app/helpers'
And the Procfile:
web: bundle exec rackup config.ru -p $PORT
I'll post my solution, if ever someone bumps into the same problem. I had followed the indication on the Rakefile here : https://github.com/sinatra-activerecord/sinatra-activerecord.
One solution was to entirely deleted the Rakefile when deploying to Heroku. The other solution is to put only this in the Rakefile :
require "sinatra/activerecord"
require "sinatra/activerecord/rake"
require "./app" # or whereever your app is
Switching to Bundler 2.1.4 solved the problem in my case.
For the longer run one will have to install bundler 2.1.4 and use it, but for the sake of test I just manually edited that line in Gemfile.lock:
BUNDLED WITH
2.1.4
I was using Ruby 2.7.2 and Bundler 2.2.8 — Heroku buildpack provided Bundler 2.1.4.
Funny that Heroku’s Bundler bugs list had nothing about 2.2.8.

How to start the rails console on Heroku with a multi-buildpack?

I'm deploying to heroku with the multi-buildpack on the cedar stack using a custom procfile:
web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config/unicorn.rb
worker: bundle exec sidekiq -e production -C config/sidekiq.yml
console: bundle exec irb -r ./console
When I boot my console with heroku run console I get LoadError: cannot load such file -- ./console and a virgin irb session.
How can I initialize the console with rails and my application environment loaded?
So running irb is obviously wrong.
What I needed was console: bundle exec rails console

Heroku dyno using thin instead of unicorn

I upgraded my app from Rails 3 to 4 and I'd like to start using Unicorn as my server. I've followed the Heroku documentation adding the Procfile and config/unicorn.rb, but when I push it runs thin.
=== web (2X): bin/rails server -p $PORT -e $RAILS_ENV
web.1: up 2014/09/09 17:45:54 (~ 1m ago)
Thin isn't in my Gemfile and I'm wondering what other potential conflicts could exist to prevent Unicorn from loading.
Procfile:
bundle exec unicorn -p $PORT -c ./config/unicorn.rb

Why is my middleman heroku app ignoring the Procfile?

I've been struggling trying to launch my middleman repo to heroku. I've followed a tutorial http://randomerrata.com/post/56163474367/middleman-on-heroku, but have had continued issues. Although installing the puma gem, for some reason the procfile is being ignored and the heroku app keeps pointing to
web bundle exec sudo unicorn_rails -c ./config/unicorn.rb -p $PORT -D --env production
Any idea how to get this thing to stop pointing to the unicorn rails and use puma?
Perhaps it would be worth checking out middleman-heroku as a different route to take. Alternatively I would check that your Gemfile.lock is up to date and committed.
I would try tailing the logs with heroku logs -t to see if you can see what's happening.
Is your Procfile called Procfile with a capital P?
What does it look like, can you post it here?
My Procfile has web: bundle exec puma -p $PORT. Is Puma listed in your Gemfile?

How to run Rack-based application (not Rails) with Unicorn

How can I run a Rack-based application (not Rails) with unicorn? Let's assume I have a "hello world" response simple rack app with the name of server.ru, and config file at the same directory with the name of unicorn.conf, how am I supposed to run it? In Thin, for example, I would do something like:
bundle exec rackup server.ru -s thin -E production -p 4001
How would I do the same to run under Unicorn?
Unicorn does not give any special treatment to Rails 3+ applications, so the behavior is exactly the same for Rails 3+ applications and non-Rails Rack applications. Just run
unicorn
in your app's root. To run with a specific port, pass -p/--port with the port:
unicorn -p 4001
You can also specify the rackup file:
unicorn server.ru
You can see all the options by running unicorn --help. Of course, you should prepend bundle exec to these commands as needed by your setup.
You can make a setting file for unicorn like this:
working_directory "/path/to/your/app"
listen 4001
pid "/tmp/unicorn.pid"
And then launch unicorn with the following command:
unicorn -c /path/to/your/setting/file.rb

Resources