title: Starting thin server on Raspberry PI on startup
body: <p>I want to start the <a href="http://code.macournoyer.com/thin/">thin</a> web server upon restart of my Raspberry Pi.</p>
  
  <p>I have the required config file in <code>/etc/thin/myapp.yml</code></p>
  
  <pre><code>---
  chdir: "/home/pi/web-interface/current"
  environment: production
  address: 0.0.0.0
  port: 3000
  timeout: 30
  log: "/home/pi/web-interface/shared/tmp/sockets/log/thin.log"
  pid: tmp/pids/thin.pid
  max_conns: 1024
  max_persistent_conns: 100
  require: []
  wait: 30
  threadpool_size: 20
  servers: 1
  daemonize: true
  </code></pre>
  
  <p>I did this to install thin as a runlevel command:</p>
  
  <pre><code>thin install
  sudo /usr/sbin/update-rc.d -f thin defaults
  </code></pre>
  
  <p>From the second command I get the following Log output</p>
  
  <pre><code>update-rc.d: using dependency based boot sequencing
  update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match thin Default-Stop values (S 0 1 6)
  insserv: warning: current stop runlevel(s) (0 1 6) of script `thin' overrides LSB defaults (0 1 6 S).
  </code></pre>
  
  <p>When I run <code>/etc/init.d/thin start</code> the server starts without trouble so there seems to be something wrong when the device starts up.</p>
  
  <p>This is <code>/etc/init.d/thin</code>:</p>
  
  <pre><code>#!/bin/sh
  ### BEGIN INIT INFO
  # Provides:          thin
  # Required-Start:    $local_fs $remote_fs
  # Required-Stop:     $local_fs $remote_fs
  # Default-Start:     2 3 4 5
  # Default-Stop:      S 0 1 6
  # Short-Description: thin initscript
  # Description:       thin
  ### END INIT INFO
  
  # Original author: Forrest Robertson
  
  # Do NOT "set -e"
  
  # DAEMON=/home/pi/.rvm/gems/ruby-2.1.0/bin/thin
  DAEMON=/home/pi/.rvm/wrappers/raspberrypi/thin
  SCRIPT_NAME=/etc/init.d/thin
  CONFIG_PATH=/etc/thin
  
  # Exit if the package is not installed
  [ -x "$DAEMON" ] || exit 0
  
  case "$1" in
    start)
          say "Starting thin"
      $DAEMON start --all $CONFIG_PATH
      ;;
    stop)
          say "Stopping thin"
      $DAEMON stop --all $CONFIG_PATH
      ;;
    restart)
      $DAEMON restart --all $CONFIG_PATH
      ;;
    *)
      echo "Usage: $SCRIPT_NAME {start|stop|restart}" &gt;&amp;2
      exit 3
      ;;
  esac
  
  :
  </code></pre>
  
  <p>Now my server does not startup up properly even though I have the following entry in my boot log:</p>
  
  <pre><code>Sat Mar  1 08:19:45 2014: [start] /etc/thin/myapp.yml ...
  Sat Mar  1 08:19:52 2014: [....] Starting NTP server: ntpd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
  Sat Mar  1 08:19:54 2014: [....] Starting OpenBSD Secure Shell server: sshd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
  Sat Mar  1 08:19:56 2014: Starting server on 0.0.0.0:3000 ... 
  Sat Mar  1 08:19:56 2014: 
  </code></pre>