[Groonga-commit] groonga/groonga [master] rpm fedora: add helper script for upgrading

Back to archive index

HAYASHI Kentaro null+****@clear*****
Tue Sep 4 17:02:51 JST 2012


HAYASHI Kentaro	2012-09-04 17:02:51 +0900 (Tue, 04 Sep 2012)

  New Revision: 2794a0ce195697317ef97fb8102d9189a0c716cd
  https://github.com/groonga/groonga/commit/2794a0ce195697317ef97fb8102d9189a0c716cd

  Log:
    rpm fedora: add helper script for upgrading

  Added files:
    packages/rpm/fedora/groonga-httpd-upgrade
  Modified files:
    packages/rpm/fedora/Makefile.am

  Modified: packages/rpm/fedora/Makefile.am (+2 -0)
===================================================================
--- packages/rpm/fedora/Makefile.am    2012-09-04 15:47:29 +0900 (321bd0c)
+++ packages/rpm/fedora/Makefile.am    2012-09-04 17:02:51 +0900 (beceaf4)
@@ -1,2 +1,4 @@
 EXTRA_DIST = groonga.spec.in
 noinst_DATA = groonga.spec
+
+sbin_SCRIPTS = groonga-httpd-upgrade

  Added: packages/rpm/fedora/groonga-httpd-upgrade (+40 -0) 100755
===================================================================
--- /dev/null
+++ packages/rpm/fedora/groonga-httpd-upgrade    2012-09-04 17:02:51 +0900 (4c4fe5d)
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+GROONGA_HTTPD=groonga-httpd
+PIDFILE=/var/run/groonga/${GROONGA_HTTPD}.pid
+OLD_PIDFILE=$PIDFILE.oldbin
+TIMEOUT=3
+
+# Source function library.
+. /etc/init.d/functions
+
+killproc -p $PIDFILE ${GROONGA_HTTPD} -USR2
+
+[ ! -f "$OLD_PIDFILE" ] && sleep $TIMEOUT
+if [ ! -f "$OLD_PIDFILE" ]; then
+	echo "Failed to start new groonga-httpd master."
+	return 1
+fi
+
+OLDPID=`cat $OLD_PIDFILE`
+
+# Switch worker process.
+kill -WINCH `cat $OLD_PIDFILE`
+
+[ ! -f "$PIDFILE" ] && sleep $TIMEOUT
+PID=`cat $PIDFILE`
+
+OLD_WORKER_PROCESS=`pgrep -P $OLDPID | grep -v $PID`
+[ -n "$OLD_WORKER_PROCESS" ] && sleep $TIMEOUT
+OLD_WORKER_PROCESS=`pgrep -P $OLDPID | 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."
+    return 2
+fi
+
+# Stop old master process.
+killproc -p $OLD_PIDFILE ${GROONGA_HTTPD} -QUIT
+return $?
+
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index