Subversion Repositories SmartDukaan

Rev

Rev 4909 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4909 amar.kumar 1
#! /bin/sh
2
### BEGIN INIT INFO
3
# Provides:          email_sender
4
# Required-Start:    $network $helper_server $config_server
5
# Default-Start:     2 3 4 5
6
# Default-Stop:      0 1 6
7
# Short-Description: Example initscript
8
# Description:       This file should be used to start the Email Sender service.
9
### END INIT INFO
10
 
11
# Author: Amar <amar.kumar@shop2020.in>
12
#
13
# Please remove the "Author" lines above and replace them
14
# with your own name if you copy and modify this script.
15
 
16
# Do NOT "set -e"
17
 
18
# PATH should only include /usr/* if it runs after the mountnfs.sh script
19
PATH=/sbin:/usr/sbin:/bin:/usr/bin
5193 rajveer 20
PROJECT_DIR="/usr/local/lib/python2.6/dist-packages/PyProj-0.1-py2.6.egg"
21
export PYTHONPATH=${PROJECT_DIR}:/usr/lib/pymodules/python2.6:/usr/lib/pymodules/python2.6/gtk-2.0:/usr/lib/python2.6:/usr/lib/python2.6/dist-packages:/usr/lib/python2.6/dist-packages/PIL:/usr/lib/python2.6/dist-packages/gst-0.10:/usr/lib/python2.6/dist-packages/gtk-2.0:/usr/lib/python2.6/lib-dynload:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/plat-linux2:/usr/local/lib/python2.6/dist-packages:/usr/local/lib/python2.6/dist-packages/Elixir-0.7.1-py2.6.egg:/usr/local/lib/python2.6/dist-packages/TracXMLRPC-0.1-py2.6.egg:/usr/local/lib/python2.6/dist-packages/tornado-1.0.1-py2.6.egg
4909 amar.kumar 22
DESC="Email Sender Service used to send mails"
23
NAME="email-sender"
24
PIDFILE=/var/run/$NAME.pid
25
DAEMON=/usr/bin/python2.6
26
SCRIPTNAME=/etc/init.d/$NAME
27
 
28
# Exit if the package is not installed
29
[ -x "$DAEMON" ] || exit 0
30
 
31
# Read configuration variable file if it is present
32
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
33
 
34
# Load the VERBOSE setting and other rcS variables
35
. /lib/init/vars.sh
36
 
37
# Define LSB log_* functions.
38
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
39
. /lib/lsb/init-functions
40
 
41
#
42
# Function that starts the daemon/service
43
#
44
do_start()
45
{
46
	# Return
47
	#   0 if daemon has been started
48
	#   1 if daemon was already running
49
	#   2 if daemon could not be started
5193 rajveer 50
        $DAEMON -u ${PROJECT_DIR}/shop2020/helpers/impl/EmailSender.py -l /var/log/services/emailsender.log -i $PIDFILE start 
4909 amar.kumar 51
	# Add code here, if necessary, that waits for the process to be ready
52
	# to handle requests from services started subsequently which depend
53
	# on this one.  As a last resort, sleep for some time.
54
}
55
 
56
#
57
# Function that stops the daemon/service
58
#
59
do_stop()
60
{
61
	# Return
62
	#   0 if daemon has been stopped
63
	#   1 if daemon was already stopped
64
	#   2 if daemon could not be stopped
65
	#   other if a failure occurred
5193 rajveer 66
        $DAEMON -u ${PROJECT_DIR}/shop2020/helpers/impl/EmailSender.py -l /var/log/services/emailsender.log -i $PIDFILE stop
4909 amar.kumar 67
	RETVAL="$?"
68
	[ "$RETVAL" = 1 ] && return 2
69
	# Wait for children to finish too if this is a daemon that forks
70
	# and if the daemon is only ever run from this initscript.
71
	# If the above conditions are not satisfied then add some other code
72
	# that waits for the process to drop all resources that could be
73
	# needed by services started subsequently.  A last resort is to
74
	# sleep for some time.
75
	#start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
76
	#[ "$?" = 2 ] && return 2
77
	# Many daemons don't delete their pidfiles when they exit.
78
	rm -f $PIDFILE
79
	return "$RETVAL"
80
}
81
 
82
#
83
# Function that sends a SIGHUP to the daemon/service
84
#
85
do_reload() {
86
	#
87
	# If the daemon can reload its configuration without
88
	# restarting (for example, when it is sent a SIGHUP),
89
	# then implement that here.
90
	#
91
	#start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
92
	return 0
93
}
94
 
95
case "$1" in
96
  start)
97
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
98
	do_start
99
	case "$?" in
100
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
101
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
102
	esac
103
	;;
104
  stop)
105
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
106
	do_stop
107
	case "$?" in
108
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
109
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
110
	esac
111
	;;
112
  status)
113
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
114
       ;;
115
  #reload|force-reload)
116
	#
117
	# If do_reload() is not implemented then leave this commented out
118
	# and leave 'force-reload' as an alias for 'restart'.
119
	#
120
	#log_daemon_msg "Reloading $DESC" "$NAME"
121
	#do_reload
122
	#log_end_msg $?
123
	#;;
124
  restart|force-reload)
125
	#
126
	# If the "reload" option is implemented then remove the
127
	# 'force-reload' alias
128
	#
129
	log_daemon_msg "Restarting $DESC" "$NAME"
130
	do_stop
131
	case "$?" in
132
	  0|1)
133
		do_start
134
		case "$?" in
135
			0) log_end_msg 0 ;;
136
			1) log_end_msg 1 ;; # Old process is still running
137
			*) log_end_msg 1 ;; # Failed to start
138
		esac
139
		;;
140
	  *)
141
	  	# Failed to stop
142
		log_end_msg 1
143
		;;
144
	esac
145
	;;
146
  *)
147
	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
148
	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
149
	exit 3
150
	;;
151
esac
152
 
153
: