Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure for which server you are talking about. But I can provide you an example for thin which supports rolling restart itself. (option <code>onebyone: true</code>) </p> <p>So for monit you can use something like,</p> <p><code>if ... then exec '/path/to/thin_restart.sh'</code></p> <p>And <code>thin_restart.sh</code> would be something like,</p> <pre><code>source /path/to/scripts/rvm rvm use your_gemset@some_ruby thin -C thin.yml restart </code></pre> <p>And contents of thin.yml would look like,</p> <pre><code>port: 1337 pid: tmp/pids/thin.pid rackup: /path/to/config.ru daemonize: true servers: 2 onebyone: true </code></pre> <p>There are other ways to fine tune this restarts based on pid. You can monitor files with pids and restart only those thin process based on conditions. </p> <p>e.g.</p> <pre><code>check process app-1337 with pid /path/to/app.1337.pid start = 'thin -d -p 1337 start' stop = 'thin -d -p 1337 -P /path/to/thin.1337.pid stop' if cpu usage &gt; 50% then restart check process app-1338 with pid /path/to/app.1338.pid start = 'thin -d -p 1338 start' stop = 'thin -d -p 1338 -P /path/to/thin.1338.pid stop' if cpu usage &gt; 50% then restart </code></pre> <p>The other way would be of using groups which monit provides.</p> <p>Extending above example.</p> <pre><code>check process app-1337 with pid /path/to/app.1337.pid group thin group thin-odd start = 'thin -d -p 1337 start' stop = 'thin -d -p 1337 -P /path/to/thin.1337.pid stop' if cpu usage &gt; 50% then restart check process app-1338 with pid /path/to/app.1338.pid group thin group thin-even start = 'thin -d -p 1338 start' stop = 'thin -d -p 1338 -P /path/to/thin.1338.pid stop' if cpu usage &gt; 50% then restart check process app-1337 with pid /path/to/app.1339.pid group thin group thin-odd start = 'thin -d -p 1339 start' stop = 'thin -d -p 1339 -P /path/to/thin.1339.pid stop' if cpu usage &gt; 50% then restart check process app-1340 with pid /path/to/app.1340.pid group thin group thin-even start = 'thin -d -p 1340 start' stop = 'thin -d -p 1340 -P /path/to/thin.1340.pid stop' if cpu usage &gt; 50% then restart </code></pre> <p>So now you can do following to restart all:</p> <pre><code>monit -g thin restart </code></pre> <p>or to achieve sort of rolling restart, restart odd ones then even. To restart only odd ones:</p> <pre><code>monit -g thin-odd restart </code></pre> <p>and to restart even:</p> <pre><code>monit -g thin-even restart </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