Note that there are some explanatory texts on larger screens.

plurals
  1. POROR, Redis, Resque, God & Cron on Ubuntu Server - Boot
    primarykey
    data
    text
    <p>I have made several jobs that god takes care of in my ruby application. However when the server reboots the job stops. I want to avoid this so I've made this script on my server. It looks like this.</p> <p><strong>my_app.sh</strong></p> <pre><code>#!/bin/bash # god tasks # case $1 in start) /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god start /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god load /usr/local/Linux/apache2/www/hej.se/ruby/config/resque.god /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god load /usr/local/Linux/apache2/www/hej.se/ruby/config/resque_schedule.god ;; esac exit 0 </code></pre> <p>If I log in manually and write </p> <blockquote> <p>"/etc/init.d/my_app start"</p> </blockquote> <p>it gives me </p> <pre><code>Sending 'start' command No matching task or group Sending 'load' command with action 'leave' The following tasks were affected: resque-0 resque-1 resque-2 resque-3 resque-4 Sending 'load' command with action 'leave' The following tasks were affected: resque_scheduler </code></pre> <p>And everything works, it does what I want it to do, i.e the jobs. </p> <p>I have tried several ways to start this script on boot (Linux 10.4.4 LTS), rc.local, rc-default and now my latest attempt is crontab.</p> <p>The script must be run under my user and not root, (it can't find the ruby installation if I run it under root).</p> <p>Because of this I've configured the crontab under my user account:</p> <pre><code>@reboot /etc/init.d/my_app start </code></pre> <p>Sadly this doesn't work... I don't what I'm doing wrong. And this should probably not be necessary. I mean shouldn't you be able to this per auto when booting up the ruby application?</p> <p>Im using passenger on this server, I don't know if this has something to do with it? </p> <p><strong>The solution below with the changes I made to the sh:</strong></p> <p>my_app.sh</p> <pre><code>bash -c "source /usr/local/rvm/scripts/rvm &amp;&amp; /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god" bash -c "source /usr/local/rvm/scripts/rvm &amp;&amp; /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god start" bash -c "source /usr/local/rvm/scripts/rvm &amp;&amp; /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god load /usr/local/Linux/apache2/www/hej.se/ruby/config/resque.god" bash -c "source /usr/local/rvm/scripts/rvm &amp;&amp; /usr/local/rvm/gems/ruby-1.9.3-p194/bin/god load /usr/local/Linux/apache2/www/hej.se/ruby/config/resque_schedule.god" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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