Using Unicorn Rack server

Unicorn is a Rack HTTP server that uses forked processes to handle multiple incoming requests concurrently.

Deploy with Unicorn

You need to choose your Rack server at the time of initial build of the application. Changes to or from Passenger (the default web app / Rack server) will not be applied after your application has initially been analyzed. You can however change freely between other supported servers by simply updating your Gems and Procfile.

To run a Unicorn Rack server, add a line to your Procfile labeled as custom_web. Here is an example:

custom_web: bundle exec unicorn_rails -c config/unicorn.rb -E $RAILS_ENV -D

Please take note that Unicorn is running in Daemon mode with the -D parameter.


Please ensure to follow the conventions set out in the configuration below if you are having issues, and that you are using an up-to-date version of Unicorn.

Here is a unicorn.rb configuration file that is compatible with Cloud 66 requirements (following the Procfile line above, this should be located under the config folder of your Rails app):

worker_processes 2

working_directory "#{ENV['STACK_PATH']}"

listen "/tmp/web_server.sock", :backlog => 64

timeout 30

pid '/tmp/'

stderr_path "#{ENV['STACK_PATH']}/log/unicorn.stderr.log"
stdout_path "#{ENV['STACK_PATH']}/log/unicorn.stdout.log"

preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
	GC.copy_on_write_friendly = true

check_client_connection false

before_fork do |server, worker|
	old_pid = '/tmp/'
	if File.exists?(old_pid) && != old_pid
		rescue Errno::ENOENT, Errno::ESRCH
			# someone else did our job for us

	defined?(ActiveRecord::Base) and

after_fork do |server, worker|
	defined?(ActiveRecord::Base) and

Controlling your Unicorn server

Cloud 66 uses the following signals to control Unicorn:

Kill the web server

Stop the web server

sudo bluepill cloud66_web_server stop

Start the web server

sudo bluepill cloud66_web_server quit
sudo bluepill load /etc/bluepill/autoload/cloud66_web_server.pill

Restart the web server (zero-downtime)

sudo bluepill cloud66_web_server restart