Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>RVM comes with a handy wrapper generator that creates an intermediary loader for an init.d script. This allows you to load a service using a particular Ruby version and gemset. I use it like this (after installing the thin gem): </p> <p>1 - create init.d entry for thin</p> <pre><code>sudo thin install </code></pre> <p>2 - set up some defaults</p> <pre><code>sudo /usr/sbin/update-rc.d -f thin defaults </code></pre> <p>3 - generate boot config for your rails app</p> <pre><code>sudo thin config -C /etc/thin/&lt;appname&gt;.yml -c /var/rails/&lt;appdir&gt; --servers 4 -e production </code></pre> <p>4 - generate rvm wrapper script</p> <pre><code>rvm wrapper &lt;rubyversion&gt;@&lt;gemset&gt; bootup thin </code></pre> <p>5 - If you're using a global gemset, you can just use</p> <pre><code>rvm wrapper ruby-1.9.2-p125 bootup thin </code></pre> <p>6 - edit thin init</p> <pre><code>sudo nano /etc/init.d/thin </code></pre> <p>7 - change the original loader</p> <pre><code>DAEMON=/usr/local/rvm/gems/ruby-&lt;rubyversion&gt;-&lt;rubyrevision&gt;@&lt;gemset&gt;/bin/thin </code></pre> <p>8 - to point to the rvm wrapper instead</p> <pre><code>DAEMON=/usr/local/bin/bootup_thin </code></pre> <p>9 - start it up</p> <pre><code>sudo service thin start </code></pre> <p>If you're running more than one app, just generate a boot config yml file for each one; when booting thin all yml files in /etc/thin/ are parsed. More info here: </p> <p><a href="http://wiki.rubyonrails.org/deployment/nginx-thin?rev=1233246014" rel="noreferrer">http://wiki.rubyonrails.org/deployment/nginx-thin?rev=1233246014</a> <em>nb: This is linking to a revision, the most current version has been edited to be empty. Consider looking at the link without the <code>?rev=...</code> in the url, the current version may be back and potentially more up to date.</em></p> <p>HTH</p> <h3>2013 BONUS EDIT</h3> <p>While I no longer use RVM in production, thin is still my production server of choice, and I still use steps 1-3 above to get started. But the default configuration it generates can do with a few tweaks, here are some of mine: </p> <p>Set the user &amp; group that thin runs as:</p> <pre><code>user: www-data group: www-data </code></pre> <p>Remove the port config and switch to using sockets instead (a little faster): </p> <pre><code># port: 3000 socket: tmp/sockets/&lt;appname&gt;.sock </code></pre> <p>Tell thin to restart instances one by one, instead of shutting them all down before starting up again (rolling restart): </p> <pre><code>onebyone: true </code></pre> <p>Give the server processes a "tag" to help identify them (in ps aux etc): </p> <pre><code>tag: &lt;appname&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload