[DRE-commits] [unicorn] 01/03: native systemd service:
Dmitry Smirnov
onlyjob at moszumanska.debian.org
Fri Jun 19 02:58:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
onlyjob pushed a commit to branch master
in repository unicorn.
commit 7f690d6
Author: Dmitry Smirnov <onlyjob at member.fsf.org>
Date: Fri Jun 19 01:49:56 2015
native systemd service:
* Build-Depends:
+ dh-systemd
* rules: use systemd helper; dh_systemd_enable override.
* added "unicorn.service" file.
* default:
- removed "CONFIGURED" variable.
- removed redundant "APP_ROOT" variable.
- removed variable extrapolation so variables could be loaded by systemd.
+ moved "-D" to init script (systemd service do not daemonize).
+ UNICORN_OPTS="-E production"
* init:
- removed check for "CONFIGURED" variable;
automatic start can be enabled by "sudo update-rc.d unicorn enable".
- removed check for "APP_ROOT" directory existance: it is redundant
because application fails with meaningful error message anyway.
This check is unnecessary and imcomplete because it does not check
for correct permissions/ownership, etc.
+ explicitly pass "-c $CONFIG_RB" to daemon along with $UNICORN_OPTS.
+ explicitly pass "-D" to daemonize since "-D" was removed from
"/etc/default/unicorn".
---
debian/control | 2 +-
debian/rules | 5 ++++-
debian/unicorn.default | 12 +++---------
debian/unicorn.init | 21 +++------------------
debian/unicorn.service | 18 ++++++++++++++++++
5 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/debian/control b/debian/control
index 9665231..de0ffda 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: ruby
Priority: optional
Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers at lists.alioth.debian.org>
Uploaders: Hleb Valoshka <375gnu at gmail.com>
-Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.5.0~), ruby-raindrops (>= 0.12.0-1~), ruby-kgio (>= 2.8.1-1~), ruby-rack, curl
+Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.5.0~), ruby-raindrops (>= 0.12.0-1~), ruby-kgio (>= 2.8.1-1~), ruby-rack, curl, dh-systemd
Standards-Version: 3.9.5
Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/unicorn.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/unicorn.git;a=summary
diff --git a/debian/rules b/debian/rules
index f50cbad..c826a57 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,7 +12,10 @@
#export DH_RUBY_GEMSPEC=gem.gemspec
%:
- dh $@ --buildsystem=ruby --with ruby
+ dh $@ --buildsystem=ruby --with ruby,systemd
override_dh_installinit:
dh_installinit --no-start
+
+override_dh_systemd_enable:
+ dh_systemd_enable --no-enable
diff --git a/debian/unicorn.default b/debian/unicorn.default
index 00e5148..b931d82 100644
--- a/debian/unicorn.default
+++ b/debian/unicorn.default
@@ -1,19 +1,13 @@
-# Change paramentres below to appropriate values and set CONFIGURED to yes.
-CONFIGURED=no
-
# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60
-# Path to your web application, sh'ld be also set in server's config.rb,
-# option "working_directory". Rack's config.ru is located here.
-APP_ROOT=/path/to/your/web/application
-
# Server's config.rb, it's not a rack's config.ru
-CONFIG_RB="$APP_ROOT/unicorn.conf.rb"
+CONFIG_RB="/path/to/your/web/application/unicorn.conf.rb"
# Where to store PID, sh'ld be also set in server's config.rb, option "pid".
+# This parameter is used by init script but not by systemd service.
PID=/run/unicorn.pid
# Additional arguments passed to unicorn, see man (1) unicorn.
-UNICORN_OPTS="-D -c $CONFIG_RB"
+UNICORN_OPTS="-E production"
diff --git a/debian/unicorn.init b/debian/unicorn.init
index 0fc4788..de5135b 100644
--- a/debian/unicorn.init
+++ b/debian/unicorn.init
@@ -34,32 +34,17 @@ exit_with_message() {
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
+ if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- -D -c $CONFIG_RB $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
@@ -80,7 +65,7 @@ case "$1" in
log_daemon_msg "Restarting $DESC" $NAME || true
start-stop-daemon --stop --quiet --oknodo --pidfile $PID
sleep 1
- if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
+ if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- -D -c $CONFIG_RB $UNICORN_OPTS; then
log_end_msg 0 || true
else
log_end_msg 1 || true
diff --git a/debian/unicorn.service b/debian/unicorn.service
new file mode 100644
index 0000000..8ac655b
--- /dev/null
+++ b/debian/unicorn.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Unicorn - Ruby web server
+Documentation=man:unicorn
+After=network.target mysql.service
+Wants=network-online.target
+
+[Service]
+#Environment=CONFIG_RB=/path/to/your/web/application/unicorn.conf.rb
+Environment=UNICORN_OPTS=-E production
+EnvironmentFile=-/etc/default/unicorn
+ExecStart=/usr/bin/unicorn -c ${CONFIG_RB} ${UNICORN_OPTS}
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=on-abort
+#User=www-data
+#Group=www-data
+
+[Install]
+WantedBy=multi-user.target
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/unicorn.git
More information about the Pkg-ruby-extras-commits
mailing list