Using Thin web server

Thin is a Ruby web server that can handle high levels of concurrency.

Deploying with Thin

You need to choose your web server at the time of initial build of the application. Changes to or from Passenger (the default web 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 Thin web server, add a line to your Procfile labeled as custom_web. Here is an example:

custom_web: bundle exec thin start --socket /tmp/web_server.sock --pid /tmp/ -e $RACK_ENV

You should not daemonize the custom_web process. In other words, please do not use the -d or -daemonize flags in your initialization string. Please also make sure your config file does not enable daemonization.

We do not support old-style daemonization because it is more reliable to allow the system’s process manager (systemd) to handle persistent processes.

Customizing shutdown and reload signals

The default shutdown command for Unicorn servers on Cloud 66 is HUP and the default shutdown sequence for applications using systemd (our default process manager) is:

quit, 75, int, 15, kill

If your application still uses Bluepill (our legacy process manager), please refer to the separate guide on the subject.

If you need your web server to shut down using a different command, or in a particular sequence, or with longer or shorter delays, you can define a custom restart sequence in the procfile_metadata section of your Manifest file.

For non-web process signals, please consult our systemd guide.

Controlling Thin via your terminal

You can manage your web server directly from your terminal. The commands you need to use will depend on whether your servers use systemd or Bluepill to manage processes. To check which process manager your application uses:

(If you’d like to migrate from Bluepill to systemd, please follow the migration checklist.)

Cloud 66 uses the following signals to control Puma via systemd:

Stop the web server

sudo systemctl stop cloud66_web_server.service

Start the web server

sudo systemctl start cloud66_web_server.service

Restart the web server

sudo systemctl restart cloud66_web_server.service

If you need more control over your restarts, you can define a custom restart sequence in the procfile_metadata section of your Manifest file.