<br><br><div class="gmail_quote">On Tue, Jun 1, 2010 at 1:25 AM, Bruno Girin <span dir="ltr"><<a href="mailto:brunogirin@gmail.com">brunogirin@gmail.com</a>></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>
><br>
><br>
> On Tue, Jun 1, 2010 at 12:05 AM, Bruno Girin <<a href="mailto:brunogirin@gmail.com">brunogirin@gmail.com</a>><br>
> wrote:<br>
> On Mon, 2010-05-31 at 23:34 +0530, Kaushal Shriyan wrote:<br>
> > Hi,<br>
> ><br>
> ><br>
> > I run the resque init script using /etc/init.d/resque start<br>
> at<br>
> > the command line which works perfectly fine while the<br>
> machine is up<br>
> > and<br>
> > running fine, The issue is it doesnot come up automatically<br>
> after<br>
> > bootup.<br>
><br>
><br>
> This is because /etc/init.d is just a repository for all<br>
> startup/shutdown scripts. You then need to configure the<br>
> script to start<br>
> on certain run-levels and stop on others. Have a look at the<br>
> wiki page<br>
> on the subject [1] (the section titled "Installing custom<br>
> init-scripts")<br>
> or do: man update-rc.d<br>
><br>
> [1] <a href="https://help.ubuntu.com/community/UbuntuBootupHowto" target="_blank">https://help.ubuntu.com/community/UbuntuBootupHowto</a><br>
><br>
> Bruno<br>
><br>
><br>
> ><br>
> ><br>
> ><br>
> > root@hoststage:~# cat /etc/init.d/resque<br>
> ><br>
> > #!/bin/bash<br>
> > # Author Kaushal Shriyan<br>
> > # Date 31/05/2010<br>
> > # Startup script for Resque Server<br>
> ><br>
> > touch /root/status<br>
> > set -e<br>
> ><br>
> ><br>
> start_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/resque_cluster_start.sh<br>
> ><br>
> stop_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/resque_cluster_stop.sh<br>
> ><br>
> > start() {<br>
> > echo -n "Starting ResqueServer: "<br>
> > ${start_resque}<br>
> > echo "starting" >> /root/status<br>
> > uptime >> /root/status<br>
> > echo "done."<br>
> > exit 0<br>
> > }<br>
> > stop() {<br>
> > echo -n "Shutting down ResqueServer: "<br>
> > ${stop_resque}<br>
> > echo "done."<br>
> > exit 0<br>
> > }<br>
> ><br>
> > # See how we were called<br>
> > case "$1" in<br>
> > start)<br>
> > start<br>
> > ;;<br>
> > stop)<br>
> > stop<br>
> > ;;<br>
> > restart)<br>
> > stop<br>
> > sleep 10<br>
> > start<br>
> > ;;<br>
> > *)<br>
> > echo "Usage: $0 {start|stop|restart}"<br>
> > esac<br>
> > root@hoststage:~#<br>
> cat /usr/local/AddressBook/EntAddressBookDataStore/<br>
> ><br>
> > current/resque_cluster_start.sh<br>
> ><br>
> > #!/bin/bash<br>
> ><br>
> ><br>
> > cd /usr/local/AddressBook/EntAddressBookDataStore/current/<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.1.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.2.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.3.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.4.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.5.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.6.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.7.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.8.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.9.log<br>
> 2>&1 &<br>
> > RAILS_ENV=production ./resque_start.sh > log/resque.10.log<br>
> 2>&1 &<br>
> > root@hoststage:~# ls<br>
> > -l /usr/local/AddressBook/EntAddressBookDataStore/<br>
> ><br>
> ><br>
> > current/resque_cluster_start.sh<br>
> ><br>
> > -rwxr-xr-x 1 root root 724 2010-05-31<br>
> 04:50 /usr/local/AddressBook/<br>
> ><br>
> > EntAddressBookDataStore/current/resque_cluster_start.sh<br>
> ><br>
> ><br>
> > #cat resque_start.sh<br>
> > #!/usr/bin/env sh<br>
> ><br>
> ><br>
> > # === GC settings =============<br>
> > # twitter's settings<br>
> > # TODO - set only for the forked process not the parent<br>
> process<br>
> > # export RUBY_HEAP_MIN_SLOTS=500000<br>
> > # export RUBY_HEAP_SLOTS_INCREMENT=250000<br>
> > # export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1<br>
> > # export RUBY_GC_MALLOC_LIMIT=50000000<br>
> > # ============================<br>
> ><br>
> ><br>
> > # required to start the redis server:<br>
> > # redis-server <path to redis.conf><br>
> ><br>
> ><br>
> > # VVERBOSE=true level of verbosity - useful for debugging<br>
> > # QUEUE=<value> the named queue to be polled<br>
> > # INTERVAL=<seconds> the interval to sleep if there is no<br>
> job in the<br>
> > queue<br>
> ><br>
> ><br>
> > # INTERVAL=60<br>
> > QUEUE=contact_import /usr/bin/env rake<br>
> -f /usr/local/AddressBook/<br>
> > EntAddressBookDataStore/current/Rakefile resque:work<br>
> #--trace<br>
> ><br>
> ><br>
> > # start the redis-web app<br>
> > #resque-web -p8282 config/initializers/load_resque.rb<br>
> ><br>
> ><br>
> > # if [ -f "/usr/local/redis/redis.conf" ]; then<br>
> > #<br>
> /usr/local/redis/redis.conf/redis-server /usr/local/redis/<br>
> > redis.conf<br>
> > # else<br>
> > #<br>
> /usr/local/redis/redis.conf/redis-server /usr/local/redis/<br>
> > redis.conf<br>
> > # fi<br>
> ><br>
> ><br>
> > root@hoststage:/etc/rc2.d#<br>
> > lrwxrwxrwx 1 root root 23 2010-05-27 06:06 S20nvidia-kernel<br>
> -> ../<br>
> > init.d/nvidia-kernel<br>
> > lrwxrwxrwx 1 root root 16 2010-05-31 05:19 S20resque<br>
> -> ../init.d/<br>
> > resque<br>
> > lrwxrwxrwx 1 root root 20 2010-05-31 05:19 S20resque_web<br>
> > -> ../init.d/<br>
> > resque_web<br>
> > root@hoststage:/etc/rc3.d# ls -l<br>
> > total 4<br>
> > lrwxrwxrwx 1 root root 16 2010-05-31 05:19 S20resque<br>
> -> ../init.d/<br>
> > resque<br>
> > lrwxrwxrwx 1 root root 20 2010-05-31 05:19 S20resque_web<br>
> > -> ../init.d/<br>
> > resque_web<br>
> > root@hoststage:/etc/rc3.d#<br>
> > total 4<br>
> > lrwxrwxrwx 1 root root 16 2010-05-31 05:19 S20resque<br>
> -> ../init.d/<br>
> > resque<br>
> > lrwxrwxrwx 1 root root 20 2010-05-31 05:19 S20resque_web<br>
> > -> ../init.d/<br>
> > resque_web<br>
> > root@hoststage:/etc/rc2.d#<br>
> > total 4<br>
> > lrwxrwxrwx 1 root root 16 2010-05-31 05:19 S20resque<br>
> -> ../init.d/<br>
> > resque<br>
> > lrwxrwxrwx 1 root root 20 2010-05-31 05:19 S20resque_web<br>
> > -> ../init.d/<br>
> > resque_web<br>
> > root@hoststage:/etc/rc4.d#<br>
> > total 4<br>
> > lrwxrwxrwx 1 root root 16 2010-05-31 05:19 S20resque<br>
> -> ../init.d/<br>
> > resque<br>
> > lrwxrwxrwx 1 root root 20 2010-05-31 05:19 S20resque_web<br>
> > -> ../init.d/<br>
> > resque_web<br>
> > root@hoststage:/etc/rc5.d#<br>
> ><br>
> ><br>
> > Please suggest further.<br>
> ><br>
> ><br>
> > Thanks and Regards<br>
> ><br>
><br>
><br>
><br>
><br>
> --<br>
> <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>
><br>
><br>
> Hi Bruno,<br>
><br>
><br>
> root:~# update-rc.d resque start 51 S .<br>
> Adding system startup for /etc/init.d/resque ...<br>
> /etc/rcS.d/S51resque -> ../init.d/resque<br>
><br>
><br>
> 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 "defaults" form that does the same thing but<br>
is a bit simpler:<br>
<br>
update-rc.d resque defaults 98 02<br>
<br>
The '98' is the start order while the '02' 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'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>