[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:06 UTC 2012


The following commit has been merged in the master branch:
commit 322c567762fc47f6b58546438d7dcbd7b76b0e3d
Author: Hleb Valoshka <375GNU at Gmail.COM>
Date:   Sun Mar 4 14:43:19 2012 +0300

    Add /etc/init.d/unicorn and /etc/default.unicorn

diff --git a/debian/unicorn.default b/debian/unicorn.default
new file mode 100644
index 0000000..d61237a
--- /dev/null
+++ b/debian/unicorn.default
@@ -0,0 +1,14 @@
+# Change paramentres below to appropriate values and set CONFIGURED to yes
+CONFIGURED=no
+
+# Default timeout until child process is killed
+TIMEOUT=60
+
+# Path to your web application
+APP_ROOT=/path/to/your/web/application
+
+# Where to store PID, sh'ld be also set in server's config.rb
+PID=/run/unicorn.pid
+
+# Additional arguments passed to unicorn, see man 1 unicorn
+UNICORN_OPTS="-D -c $APP_ROOT/config/unicorn.rb"
diff --git a/debian/unicorn.init b/debian/unicorn.init
new file mode 100644
index 0000000..00207bb
--- /dev/null
+++ b/debian/unicorn.init
@@ -0,0 +1,109 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          unicorn
+# Required-Start:    $local_fs $remote_fs
+# Required-Stop:     $local_fs $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: unicorn initscript
+# Description:       unicorn
+### END INIT INFO
+
+set -e
+
+NAME=unicorn
+DESC="Unicorn web server"
+
+. /lib/lsb/init-functions
+
+if [ -f /etc/default/unicorn ]; then
+  . /etc/default/unicorn
+fi
+
+DAEMON=/usr/bin/unicorn
+TIMEOUT=${TIMEOUT-60}
+PID=${PID-/run/unicorn.pid}
+
+run_by_init() {
+    ([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
+}
+
+exit_with_message() {
+  if ! run_by_init; then
+    log_action_msg "$1 Not starting."
+  fi
+  exit 0
+}
+
+check_config() {
+  if [ $CONFIGURED != "yes" ]; then
+    exit_with_message "Unicorn is not configured (see /etc/default/unicorn)."
+  fi
+}
+
+check_app_root() {
+  if ! [ -d $APP_ROOT ]; then
+    exit_with_message "Application directory $APP_ROOT is not exist."
+  fi
+}
+
+set -u
+
+case "$1" in
+  start)
+        check_config
+        check_app_root
+
+        log_daemon_msg "Starting $DESC" $NAME || true
+        if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
+          log_end_msg 0 || true
+        else
+          log_end_msg 1 || true
+        fi
+	      ;;
+  stop)
+        log_daemon_msg "Stopping $DESC" $NAME || true
+        if start-stop-daemon --stop --signal QUIT --quiet --oknodo --pidfile $PID; then
+          log_end_msg 0 || true
+        else
+          log_end_msg 1 || true
+        fi
+        ;;
+  force-stop)
+        log_daemon_msg "Forcing stop of $DESC" $NAME || true
+        if start-stop-daemon --stop --quiet --oknodo --pidfile $PID; then
+          log_end_msg 0 || true
+        else
+          log_end_msg 1 || true
+        fi
+        ;;
+  restart|force-reload)
+        log_daemon_msg "Restarting $DESC" $NAME || true
+        start-stop-daemon --stop --quiet --oknodo --pidfile $PID
+        sleep 1
+        start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS
+        ;;
+  reload)
+        log_daemon_msg "Reloading $DESC" $NAME || true
+        if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID; then
+          log_end_msg 0 || true
+        else
+          log_end_msg 1 || true
+        fi
+        ;;
+  reopen-logs)
+        log_daemon_msg "Relopening log files of $DESC" $NAME || true
+        if start-stop-daemon --stop --signal USR1 --quiet --oknodo --pidfile $PID; then
+          log_end_msg 0 || true
+        else
+          log_end_msg 1 || true
+        fi
+        ;;
+  status)
+        status_of_proc -p $PID $DAEMON $NAME && exit 0 || exit $?
+        ;;
+  *)
+        log_action_msg "Usage: $0 <start|stop|restart|force-reload|reload|force-stop|reopen-logs|status>" || true
+        exit 1
+        ;;
+esac

-- 
unicorn.git



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