<br><br><div class="gmail_quote">On Tue, Jun 1, 2010 at 1:25 AM, Bruno Girin <span dir="ltr">&lt;<a href="mailto:brunogirin@gmail.com">brunogirin@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div><div></div><div class="h5">On Tue, 2010-06-01 at 00:12 +0530, Kaushal Shriyan wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jun 1, 2010 at 12:05 AM, Bruno Girin &lt;<a href="mailto:brunogirin@gmail.com">brunogirin@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;         On Mon, 2010-05-31 at 23:34 +0530, Kaushal Shriyan wrote:<br>
&gt;         &gt; Hi,<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; I run the resque init script using /etc/init.d/resque start<br>
&gt;         at<br>
&gt;         &gt; the command line which works perfectly fine while the<br>
&gt;         machine is up<br>
&gt;         &gt; and<br>
&gt;         &gt; running fine, The issue is it doesnot come up automatically<br>
&gt;         after<br>
&gt;         &gt; bootup.<br>
&gt;<br>
&gt;<br>
&gt;         This is because /etc/init.d is just a repository for all<br>
&gt;         startup/shutdown scripts. You then need to configure the<br>
&gt;         script to start<br>
&gt;         on certain run-levels and stop on others. Have a look at the<br>
&gt;         wiki page<br>
&gt;         on the subject [1] (the section titled &quot;Installing custom<br>
&gt;         init-scripts&quot;)<br>
&gt;         or do: man update-rc.d<br>
&gt;<br>
&gt;         [1] <a href="https://help.ubuntu.com/community/UbuntuBootupHowto" target="_blank">https://help.ubuntu.com/community/UbuntuBootupHowto</a><br>
&gt;<br>
&gt;         Bruno<br>
&gt;<br>
&gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; root@hoststage:~# cat /etc/init.d/resque<br>
&gt;         &gt;<br>
&gt;         &gt; #!/bin/bash<br>
&gt;         &gt; # Author Kaushal Shriyan<br>
&gt;         &gt; # Date 31/05/2010<br>
&gt;         &gt; # Startup script for Resque Server<br>
&gt;         &gt;<br>
&gt;         &gt; touch /root/status<br>
&gt;         &gt; set -e<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         start_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/resque_cluster_start.sh<br>
&gt;         &gt;<br>
&gt;         stop_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/resque_cluster_stop.sh<br>
&gt;         &gt;<br>
&gt;         &gt; start() {<br>
&gt;         &gt;         echo -n &quot;Starting ResqueServer: &quot;<br>
&gt;         &gt;         ${start_resque}<br>
&gt;         &gt;         echo &quot;starting&quot; &gt;&gt; /root/status<br>
&gt;         &gt;         uptime &gt;&gt; /root/status<br>
&gt;         &gt;         echo &quot;done.&quot;<br>
&gt;         &gt;         exit 0<br>
&gt;         &gt; }<br>
&gt;         &gt; stop() {<br>
&gt;         &gt;         echo -n &quot;Shutting down ResqueServer: &quot;<br>
&gt;         &gt;         ${stop_resque}<br>
&gt;         &gt;         echo &quot;done.&quot;<br>
&gt;         &gt;         exit 0<br>
&gt;         &gt; }<br>
&gt;         &gt;<br>
&gt;         &gt; # See how we were called<br>
&gt;         &gt; case &quot;$1&quot; in<br>
&gt;         &gt;   start)<br>
&gt;         &gt;         start<br>
&gt;         &gt;         ;;<br>
&gt;         &gt;   stop)<br>
&gt;         &gt;         stop<br>
&gt;         &gt;         ;;<br>
&gt;         &gt;   restart)<br>
&gt;         &gt;         stop<br>
&gt;         &gt;         sleep 10<br>
&gt;         &gt;         start<br>
&gt;         &gt;         ;;<br>
&gt;         &gt;   *)<br>
&gt;         &gt;         echo &quot;Usage: $0 {start|stop|restart}&quot;<br>
&gt;         &gt; esac<br>
&gt;         &gt; root@hoststage:~#<br>
&gt;         cat /usr/local/AddressBook/EntAddressBookDataStore/<br>
&gt;         &gt;<br>
&gt;         &gt; current/resque_cluster_start.sh<br>
&gt;         &gt;<br>
&gt;         &gt; #!/bin/bash<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; cd /usr/local/AddressBook/EntAddressBookDataStore/current/<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.1.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.2.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.3.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.4.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.5.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.6.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.7.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.8.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.9.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; RAILS_ENV=production ./resque_start.sh &gt; log/resque.10.log<br>
&gt;         2&gt;&amp;1 &amp;<br>
&gt;         &gt; root@hoststage:~# ls<br>
&gt;         &gt; -l /usr/local/AddressBook/EntAddressBookDataStore/<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; current/resque_cluster_start.sh<br>
&gt;         &gt;<br>
&gt;         &gt; -rwxr-xr-x 1 root root 724 2010-05-31<br>
&gt;         04:50 /usr/local/AddressBook/<br>
&gt;         &gt;<br>
&gt;         &gt; EntAddressBookDataStore/current/resque_cluster_start.sh<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; #cat resque_start.sh<br>
&gt;         &gt; #!/usr/bin/env sh<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; # === GC settings =============<br>
&gt;         &gt; # twitter&#39;s settings<br>
&gt;         &gt; # TODO - set only for the forked process not the parent<br>
&gt;         process<br>
&gt;         &gt; # export RUBY_HEAP_MIN_SLOTS=500000<br>
&gt;         &gt; # export RUBY_HEAP_SLOTS_INCREMENT=250000<br>
&gt;         &gt; # export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1<br>
&gt;         &gt; # export RUBY_GC_MALLOC_LIMIT=50000000<br>
&gt;         &gt; # ============================<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; # required to start the redis server:<br>
&gt;         &gt; # redis-server &lt;path to redis.conf&gt;<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; # VVERBOSE=true level of verbosity - useful for debugging<br>
&gt;         &gt; # QUEUE=&lt;value&gt; the named queue to be polled<br>
&gt;         &gt; # INTERVAL=&lt;seconds&gt; the interval to sleep if there is no<br>
&gt;         job in the<br>
&gt;         &gt; queue<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; # INTERVAL=60<br>
&gt;         &gt; QUEUE=contact_import /usr/bin/env rake<br>
&gt;         -f /usr/local/AddressBook/<br>
&gt;         &gt; EntAddressBookDataStore/current/Rakefile resque:work<br>
&gt;         #--trace<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; # start the redis-web app<br>
&gt;         &gt; #resque-web -p8282 config/initializers/load_resque.rb<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; # if [ -f &quot;/usr/local/redis/redis.conf&quot; ]; then<br>
&gt;         &gt; #<br>
&gt;           /usr/local/redis/redis.conf/redis-server /usr/local/redis/<br>
&gt;         &gt; redis.conf<br>
&gt;         &gt; # else<br>
&gt;         &gt; #<br>
&gt;           /usr/local/redis/redis.conf/redis-server /usr/local/redis/<br>
&gt;         &gt; redis.conf<br>
&gt;         &gt; # fi<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; root@hoststage:/etc/rc2.d#<br>
&gt;         &gt; lrwxrwxrwx 1 root root  23 2010-05-27 06:06 S20nvidia-kernel<br>
&gt;         -&gt; ../<br>
&gt;         &gt; init.d/nvidia-kernel<br>
&gt;         &gt; lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque<br>
&gt;         -&gt; ../init.d/<br>
&gt;         &gt; resque<br>
&gt;         &gt; lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web<br>
&gt;         &gt; -&gt; ../init.d/<br>
&gt;         &gt; resque_web<br>
&gt;         &gt; root@hoststage:/etc/rc3.d# ls -l<br>
&gt;         &gt; total 4<br>
&gt;         &gt; lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque<br>
&gt;         -&gt; ../init.d/<br>
&gt;         &gt; resque<br>
&gt;         &gt; lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web<br>
&gt;         &gt; -&gt; ../init.d/<br>
&gt;         &gt; resque_web<br>
&gt;         &gt; root@hoststage:/etc/rc3.d#<br>
&gt;         &gt; total 4<br>
&gt;         &gt; lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque<br>
&gt;         -&gt; ../init.d/<br>
&gt;         &gt; resque<br>
&gt;         &gt; lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web<br>
&gt;         &gt; -&gt; ../init.d/<br>
&gt;         &gt; resque_web<br>
&gt;         &gt; root@hoststage:/etc/rc2.d#<br>
&gt;         &gt; total 4<br>
&gt;         &gt; lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque<br>
&gt;         -&gt; ../init.d/<br>
&gt;         &gt; resque<br>
&gt;         &gt; lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web<br>
&gt;         &gt; -&gt; ../init.d/<br>
&gt;         &gt; resque_web<br>
&gt;         &gt; root@hoststage:/etc/rc4.d#<br>
&gt;         &gt; total 4<br>
&gt;         &gt; lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque<br>
&gt;         -&gt; ../init.d/<br>
&gt;         &gt; resque<br>
&gt;         &gt; lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web<br>
&gt;         &gt; -&gt; ../init.d/<br>
&gt;         &gt; resque_web<br>
&gt;         &gt; root@hoststage:/etc/rc5.d#<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; Please suggest further.<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; Thanks and Regards<br>
&gt;         &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;         --<br>
&gt;         <a href="mailto:ubuntu-uk@lists.ubuntu.com">ubuntu-uk@lists.ubuntu.com</a><br>
&gt;         <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk</a><br>
&gt;         <a href="https://wiki.ubuntu.com/UKTeam/" target="_blank">https://wiki.ubuntu.com/UKTeam/</a><br>
&gt;<br>
&gt;<br>
&gt; Hi Bruno,<br>
&gt;<br>
&gt;<br>
&gt; root:~# update-rc.d resque start 51 S .<br>
&gt;  Adding system startup for /etc/init.d/resque ...<br>
&gt;    /etc/rcS.d/S51resque -&gt; ../init.d/resque<br>
&gt;<br>
&gt;<br>
&gt; did not work this time too<br>
<br>
</div></div>The example on the wiki is not great. You probably want the service to<br>
start on run levels 2, 3, 4 and 5, after everything else has started;<br>
and stop on run level 0, 1 and 6 before anything else stops, in which<br>
case, you would issue the following:<br>
<br>
update-rc.d resque start 98 2 3 4 5 . stop 02 0 1 6 .<br>
<br>
Alternatively, there is a &quot;defaults&quot; form that does the same thing but<br>
is a bit simpler:<br>
<br>
update-rc.d resque defaults 98 02<br>
<br>
The &#39;98&#39; is the start order while the &#39;02&#39; is the stop order, both being<br>
values between 00 and 99. So the commands above will ensure that your<br>
service starts very late in the sequence (so everything it depends on<br>
should already be started)  but is stopped very early when the machine<br>
shuts down.<br>
<br>
And don&#39;t forget to remove the /etc/rcS.d/S51resque symlink you<br>
accidentally created earlier by following the wiki.<br>
<br>
For some background info, Linux (and any other System V operating system<br>
like Sun Solaris) uses run levels to manage what services start and stop<br>
during startup and shutdown. Run levels 2, 3, 4 and 5 are the standard<br>
multi-user modes and are identical on a default install, 0 is the run<br>
level used when shutting down, 1 when in single user mode and 6 when<br>
rebooting. More details on debiandadmin [1].<br>
<br>
By default, a Ubuntu box will start in run level 2. Run levels 3, 4 and<br>
5 are generally not used but are made available so that you could<br>
customise them and have specific services running only in controlled<br>
circumstances. For example Solaris used to (and maybe still does) have<br>
core services started on run level 2 but added extra services that were<br>
considered potentially unsafe in run level 3 (such as the telnet and ftp<br>
daemons). By doing this, you could easily start all those services by<br>
changing to run level 3 and stop them again by dropping to run level 2.<br>
<br>
[1] <a href="http://www.debianadmin.com/debian-and-ubuntu-linux-run-levels.html" target="_blank">http://www.debianadmin.com/debian-and-ubuntu-linux-run-levels.html</a><br>
<br>
Bruno -- off to update the wiki with a more sensible example<br>
<font color="#888888"><br>
<br>
<br>
--<br>
</font><div><div></div><div class="h5"><a href="mailto:ubuntu-uk@lists.ubuntu.com">ubuntu-uk@lists.ubuntu.com</a><br>
<a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk</a><br>
<a href="https://wiki.ubuntu.com/UKTeam/" target="_blank">https://wiki.ubuntu.com/UKTeam/</a><br>
</div></div></blockquote></div><br>Hi Bruno<br><br>It did not worked this time too. Please suggest further.<br><br>Thanks,<br><br>Kaushal<br><br>