add changelog for 1.13
[beanstalkd.git] / adm / systemv / beanstalkd.init
blob81db524923b2a5163787cd5446a7aa7983c898f3
1 #!/bin/sh
3 # System V init script in charge of starting/stopping beanstalkd
5 # chkconfig: - 57 47
6 # description: beanstalkd is a simple, fast work queue
7 # processname: beanstalkd
8 # config: /etc/sysconfig/beanstalkd
9 # pidfile: /var/run/beanstalkd/beanstalkd.pid
11 ### BEGIN INIT INFO
12 # Provides: beanstalkd
13 # Required-Start: $local_fs $network $remote_fs
14 # Required-Stop: $local_fs $network $remote_fs
15 # Default-Stop: 0 1 2 6
16 # Short-Description: start and stop beanstalkd
17 # Description: beanstalkd is a simple, fast work queue
18 ### END INIT INFO
20 # Source function library
21 . /etc/rc.d/init.d/functions
23 # Source networking configuration
24 . /etc/sysconfig/network
26 # Check that networking is up
27 [ "$NETWORKING" = "no" ] && exit
29 exec="/usr/bin/beanstalkd"
30 prog=$(basename $exec)
32 # Default options, overruled by items in sysconfig
33 BEANSTALKD_ADDR=127.0.0.1
34 BEANSTALKD_PORT=11300
35 BEANSTALKD_USER=beanstalkd
37 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
39 lockfile=/var/lock/subsys/$prog
41 start() {
42 [ -x $exec ] || exit 5
43 echo -n $"Starting $prog: "
45 options="-l $BEANSTALKD_ADDR -p $BEANSTALKD_PORT -u $BEANSTALKD_USER"
47 [ -n "$BEANSTALKD_MAX_JOB_SIZE" ] && options="$options -z $BEANSTALKD_MAX_JOB_SIZE"
49 if [ -n "$BEANSTALKD_BINLOG_DIR" ]; then
50 if [ ! -d "$BEANSTALKD_BINLOG_DIR" ]; then
51 echo "Creating binlog directory ($BEANSTALKD_BINLOG_DIR)"
52 mkdir -p $BEANSTALKD_BINLOG_DIR
53 chown $BEANSTALKD_USER:$BEANSTALKD_USER $BEANSTALKD_BINLOG_DIR
56 options="$options -b $BEANSTALKD_BINLOG_DIR"
58 if [ -n "$BEANSTALKD_BINLOG_FSYNC_PERIOD" ]; then
59 options="$options -f $BEANSTALKD_BINLOG_FSYNC_PERIOD"
60 else
61 options="$options -F"
64 if [ -n "$BEANSTALKD_BINLOG_SIZE" ]; then
65 options="$options -s $BEANSTALKD_BINLOG_SIZE"
69 daemon "nohup $exec $options > /dev/null 2>&1 &"
70 retval=$?
71 echo
72 [ $retval -eq 0 ] && touch $lockfile
73 return $retval
76 stop() {
77 echo -n $"Stopping $prog: "
78 killproc $prog
79 retval=$?
80 echo
81 [ $retval -eq 0 ] && rm -f $lockfile
82 return $retval
85 restart() {
86 stop
87 start
90 reload() {
91 restart
94 force_reload() {
95 restart
98 rh_status() {
99 # Run checks to determine if the service is running or use generic status
100 status $prog
103 rh_status_q() {
104 rh_status >/dev/null 2>&1
107 case "$1" in
108 start)
109 rh_status_q && exit 0
112 stop)
113 rh_status_q || exit 0
116 restart)
119 reload)
120 rh_status_q || exit 7
123 force-reload)
124 force_reload
126 status)
127 rh_status
129 condrestart|try-restart)
130 rh_status_q || exit 0
131 restart
134 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
135 exit 2
136 esac
137 exit $?