shell script - resque

Kaushal Shriyan kaushalshriyan at gmail.com
Mon May 31 16:56:12 UTC 2010


On Mon, May 31, 2010 at 7:36 PM, Kaushal Shriyan
<kaushalshriyan at gmail.com>wrote:

> Hi,
>
> I have the below init shell script. While i run it by hand it works
> perfectly fine, but does not start automatically after boot up. I have run
> the command update-rc.d resque defaults.
> Please suggest/guide.
>
> #!/bin/bash
> # Author Kaushal Shriyan
> # Date 31/05/2010
> # Startup script for Resque Server
>
> touch /root/status
> set -e
>
>
> start_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/resque_cluster_start.sh
>
> stop_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/resque_cluster_stop.sh
>
> start() {
>         echo -n "Starting ResqueServer: "
>         ${start_resque}
>         echo "starting" >> /root/status
>         uptime >> /root/status
>         echo "done."
>         exit 0
> }
> stop() {
>         echo -n "Shutting down ResqueServer: "
>         ${stop_resque}
>         echo "done."
>         exit 0
> }
>
> # See how we were called
> case "$1" in
>   start)
>         start
>         ;;
>   stop)
>         stop
>         ;;
>   restart)
>         stop
>         sleep 10
>         start
>         ;;
>   *)
>         echo "Usage: $0 {start|stop|restart}"
> esac
>
>
Hi Again,

I run the resque init script using /etc/init.d/resque start at the
command line which works perfectly fine while the machine is up and
running fine, The issue is it doesnot come up automatically after
bootup.
root at hoststage:~# cat /etc/init.d/resque
#!/bin/bash
# Author Kaushal Shriyan
# Date 31/05/2010
# Startup script for Resque Server

touch /root/status
set -e

start_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/
resque_cluster_start.sh
stop_resque=/usr/local/AddressBook/EntAddressBookDataStore/current/
resque_cluster_stop.sh

start() {
        echo -n "Starting ResqueServer: "
        ${start_resque}
        echo "starting" >> /root/status
        uptime >> /root/status
        echo "done."
        exit 0
}

stop() {
        echo -n "Shutting down ResqueServer: "
        ${stop_resque}
        echo "done."
        exit 0

}

# See how we were called
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 10
        start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
esac

root at hoststage:~# cat /usr/local/AddressBook/EntAddressBookDataStore/
current/resque_cluster_start.sh
#!/bin/bash

cd /usr/local/AddressBook/EntAddressBookDataStore/current/
RAILS_ENV=production ./resque_start.sh > log/resque.1.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.2.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.3.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.4.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.5.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.6.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.7.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.8.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.9.log 2>&1 &
RAILS_ENV=production ./resque_start.sh > log/resque.10.log 2>&1 &
root at hoststage:~# ls -l /usr/local/AddressBook/EntAddressBookDataStore/
current/resque_cluster_start.sh
-rwxr-xr-x 1 root root 724 2010-05-31 04:50 /usr/local/AddressBook/
EntAddressBookDataStore/current/resque_cluster_start.sh

#cat resque_start.sh
#!/usr/bin/env sh

# === GC settings =============
# twitter's settings
# TODO - set only for the forked process not the parent process
# export RUBY_HEAP_MIN_SLOTS=500000
# export RUBY_HEAP_SLOTS_INCREMENT=250000
# export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
# export RUBY_GC_MALLOC_LIMIT=50000000
# ============================

# required to start the redis server:
# redis-server <path to redis.conf>

# VVERBOSE=true level of verbosity - useful for debugging
# QUEUE=<value> the named queue to be polled
# INTERVAL=<seconds> the interval to sleep if there is no job in the
queue

# INTERVAL=60
QUEUE=contact_import /usr/bin/env rake -f /usr/local/AddressBook/
EntAddressBookDataStore/current/Rakefile resque:work #--trace

# start the redis-web app
#resque-web -p8282 config/initializers/load_resque.rb

# if [ -f "/usr/local/redis/redis.conf" ]; then
#     /usr/local/redis/redis.conf/redis-server /usr/local/redis/
redis.conf
# else
#     /usr/local/redis/redis.conf/redis-server /usr/local/redis/
redis.conf
# fi

root at hoststage:/etc/rc2.d#
lrwxrwxrwx 1 root root  23 2010-05-27 06:06 S20nvidia-kernel -> ../
init.d/nvidia-kernel
lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque -> ../init.d/
resque
lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web -> ../init.d/
resque_web
root at hoststage:/etc/rc3.d# ls -l
total 4
lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque -> ../init.d/
resque
lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web -> ../init.d/
resque_web
root at hoststage:/etc/rc3.d#
total 4
lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque -> ../init.d/
resque
lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web -> ../init.d/
resque_web
root at hoststage:/etc/rc2.d#
total 4
lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque -> ../init.d/
resque
lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web -> ../init.d/
resque_web
root at hoststage:/etc/rc4.d#
total 4
lrwxrwxrwx 1 root root  16 2010-05-31 05:19 S20resque -> ../init.d/
resque
lrwxrwxrwx 1 root root  20 2010-05-31 05:19 S20resque_web -> ../init.d/
resque_web
root at hoststage:/etc/rc5.d#

Please suggest further.

Thanks and Regards

Kaushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-server/attachments/20100531/ea1ec264/attachment.html>


More information about the ubuntu-server mailing list