Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a very simple Ruby application which uses Thin and Bundler that I need to stick on an Ubuntu box.

I've got as far as getting Ruby, bundler etc installed on the server, but am having trouble running the application itself.

Essentially I need a nice way of starting, stopping and restarting the application via capistrano.

My init.d script looks pretty much like this:


# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

case "$1" in
        cd /home/ubuntu/apps/my_app/current && bundle exec thin start -d -C /etc/thin/my_app.yml
        cd /home/ubuntu/apps/my_app/current && bundle exec thin stop -d -C /etc/thin/my_app.yml
        cd /home/ubuntu/apps/my_app/current && bundle exec thin restart -d -C /etc/thin/my_app.yml
        echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
        exit 3

This results in:

/home/ubuntu/apps/my_app/shared/bundle/ruby/1.8/gems/thin-1.3.1/lib/thin/daemonizing.rb:51:in `daemonize': uninitialized constant Thin::Daemonizable::Daemonize (NameError)

Running sudo bundle exec thin start from the application root on the server works just fine (although not as a daemon).

Therefore, how can I set this application up so that it'll start up as a daemon and be controllable via an init.d script / monit etc?

share|improve this question
up vote 2 down vote accepted

You could create binstubs. using these the init-script should be like any other. thin just needs --damonize as parameter if you do not specify it in your thin.yaml. With thin install thin generates an init-script for you


If you use the --binstubs flag in bundle install(1), Bundler will automatically create a directory (which defaults to app_root/bin) containing all of the executables available from gems in the bundle.

After using --binstubs, bin/rspec spec/my_spec.rb is identical to bundle exec rspec spec/my_spec.rb.

Based on these features this works for me:

bundle install --binstubs
./bin/thin install
/etc/init.d/thin start
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.