[DRE-commits] [SCM] unicorn.git branch, master, updated. upstream/4.2.0-13-gb17d23c

Hleb Valoshka 375GNU at Gmail.COM
Sun Mar 4 17:35:07 UTC 2012


The following commit has been merged in the master branch:
commit 66325d273bb96bee00911b70e2bee18f4c8228ff
Author: Hleb Valoshka <375GNU at Gmail.COM>
Date:   Sun Mar 4 14:57:10 2012 +0300

    Post install script

diff --git a/debian/unicorn.postinst b/debian/unicorn.postinst
new file mode 100644
index 0000000..423d5a5
--- /dev/null
+++ b/debian/unicorn.postinst
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+set -e
+
+if [ $1 != "configure" ] ; then
+  exit 0
+fi
+
+if [ -f /etc/default/unicorn ]; then
+  . /etc/default/unicorn
+fi
+
+DAEMON=/usr/bin/unicorn
+TIMEOUT=${TIMEOUT-60}
+PID=${PID-/run/unicorn.pid}
+OLDPID="${PID}.oldbin"
+
+invoke() {
+  if [ -x /usr/sbin/invoke-rc.d ]; then
+    invoke-rc.d $1 $2
+  else
+    /etc/init.d/$1 $2
+  fi
+}
+
+running() {
+  invoke $1 status
+}
+
+sig () {
+  test -s "$PID" && kill -$1 `cat $PID`
+}
+
+oldsig () {
+  test -s $OLD_PID && kill -$1 `cat $OLD_PID`
+}
+
+upgrade() {
+  echo "Trying to upgrade running server"
+  if sig USR2 && sleep 2 && sig 0 && oldsig QUIT ; then
+    n=$TIMEOUT
+    while test -s $OLD_PID && test $n -ge 0 ; do
+      printf '.' && sleep 1 && n=`expr $n - 1`
+    done
+
+    if test $n -lt 0 && test -s $OLD_PID; then
+      echo "$OLD_PID still exists after $TIMEOUT seconds. Killing and starting new."
+      sig KILL || true
+      oldsig KILL || true
+      invoke unicorn start
+    fi
+  fi
+}
+
+if [ -x /etc/init.d/unicorn ]; then
+    if ( running unicorn ) ; then
+      upgrade
+    else
+      invoke unicorn start
+    fi
+fi
+
+#DEBHELPER#
+
+exit 0

-- 
unicorn.git



More information about the Pkg-ruby-extras-commits mailing list