Sha256: 6770fea8b785910ccdfa94fd74d72ddd6ba1819286a50281a4ca7b401fbd7438

Contents?: true

Size: 1.59 KB

Versions: 11

Compression:

Stored size: 1.59 KB

Contents

#!/bin/sh

GROONGA_HTTPD=groonga-httpd
PIDFILE=/var/run/groonga/${GROONGA_HTTPD}.pid
OLD_PIDFILE=$PIDFILE.oldbin
STATUS_TIMEOUT=3

# Source function library.
if [ -f /lib/lsb/init-functions ]; then
    . /lib/lsb/init-functions
    if [ -f /etc/default/$GROONGA_HTTPD ]; then
	. /etc/default/$GROONGA_HTTPD
    fi
elif [ -f /etc/init.d/functions ]; then
    . /etc/init.d/functions
    if [ -f /etc/sysconfig/$GROONGA_HTTPD ]; then
	. /etc/sysconfig/$GROONGA_HTTPD
    fi
fi

wait_until_file_is_created () {
	timeout $STATUS_TIMEOUT tail -F $1 --quiet 2> /dev/null | read 2> /dev/null
}

wait_until_process_is_finished () {
	timeout $STATUS_TIMEOUT tail -F /dev/null --pid=$1
}

if [ "$1" = "try-restart" ]; then
	if [ ! -f "$PIDFILE" ]; then
		exit 0
	fi
fi

killproc -p $PIDFILE ${GROONGA_HTTPD} -USR2

wait_until_file_is_created $OLD_PIDFILE
if [ ! -f "$OLD_PIDFILE" ]; then
	echo "Failed to start new groonga-httpd master."
	exit 1
fi

OLD_PID=`cat $OLD_PIDFILE`

# Switch worker process.
kill -WINCH `cat $OLD_PIDFILE`

wait_until_file_is_created $PIDFILE
if [ ! -f "$PIDFILE" ]; then
	echo "Failed to switch worker process."
	exit 2
fi
PID=`cat $PIDFILE`

OLD_WORKER_PROCESS=`pgrep -P $OLD_PID | grep -v $PID`
for pid in $OLD_WORKER_PROCESS; do
	wait_until_process_is_finished $pid
done
OLD_WORKER_PROCESS=`pgrep -P $OLD_PID | grep -v $PID`
if [ -n "$OLD_WORKER_PROCESS" ]; then
	echo "Failed to stop old groonga-httpd worker process."
	killproc -p $PIDFILE ${GROONGA_HTTPD} -QUIT
	echo "Rollback to old groonga-httpd master."
	exit 2
fi

# Stop old master process.
killproc -p $OLD_PIDFILE ${GROONGA_HTTPD} -QUIT
exit $?

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rroonga-3.0.7-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-3.0.6-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-3.0.5-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-3.0.4-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-3.0.2-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-3.0.1-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-3.0.0-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-2.1.3-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-2.1.2-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-2.1.1-x86-mingw32 vendor/local/sbin/groonga-httpd-restart
rroonga-2.1.0-x86-mingw32 vendor/local/sbin/groonga-httpd-restart