[Heroku] How to Change WebServer from WEBrick to thin - [Rails 3.x on Heroku/Cedar]
When you simply deploy a Rails app to Heroku in its initial state, the web server runs on WEBrick.
$ heroku ps
Process State Command
------- ------------ ---------------------------------
web.1 idle for 94h bundle exec rails server -p $PORT
WebserverBy default, your app’s web process runs rails server, which uses Webrick. This is fine for testing, but for production apps you’ll want to switch to a more robust webserver. We recommend Thin.
To use Thin with Rails 3, add it to your Gemfile:
gem 'thin'Run bundle install to set up your bundle locally.
■ Creating/Adding to Procfile
web: bundle exec rails server thin -p $PORT -e $RACK_ENV
echo "RACK_ENV=development" >>.env
Add to .gitignore to ignore .env.
# Ignore Heroku for local config
/.env
■ Installing Foreman
$ gem install foreman
■ Starting Foreman
Start Foreman and access http://localhost:5000/ from your browser to verify.
$ foreman start
■ Deploy to Heroku
$ git add -A
$ git commit -m "use thin via procfile"
$ git push heroku
■ Verify it’s running with thin
$ heroku ps
Process State Command
------- ----------- ------------------------------------
web.1 idle for 4m bundle exec rails server thin -p $..
That’s all.
【References】
・Getting Started with Rails 3.x on Heroku/Cedar | Heroku Dev Center
・The Process Model | Heroku Dev Center
・Fiberを使ってem-http-requestとかを同期的に呼び出す - daily gimite
・Issue #13: FiberError with Rails 3.1 on Heroku · mperham/rack-fiber_pool · GitHub
・mperham/rack-fiber_pool · GitHub
That’s all from the Gemba.