aboutsummaryrefslogtreecommitdiffstats
path: root/main/nginx/nginx.initd
diff options
context:
space:
mode:
authorValery Kartel <valery.kartel@gmail.com>2016-01-27 18:29:37 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2016-02-10 10:17:41 +0000
commit0652a487124c622df7f72c3d574e1dd90bae0bff (patch)
treeec4abea80c9b77b03230840ebe4696eab52fbd02 /main/nginx/nginx.initd
parent1060dd05080d3ef893f66f9ef8ab3b89bfa78462 (diff)
downloadaports-0652a487124c622df7f72c3d574e1dd90bae0bff.tar.bz2
aports-0652a487124c622df7f72c3d574e1dd90bae0bff.tar.xz
main/nginx: completely rewritten, all nginx-* packages are assembled in this one
- nginx-common - config-files, init-scripts and common data - nginx - binary without external modules - nginx-rtmp - binary with rtmp module - nginx-lua - binary with rtmp and lua modules - init-script cleaned up to be more openrc-run'ed - logrotate cleaned up to use new init-script Packages main/nginx-initscripts and main/nginx-lua no longer needed.
Diffstat (limited to 'main/nginx/nginx.initd')
-rw-r--r--main/nginx/nginx.initd66
1 files changed, 66 insertions, 0 deletions
diff --git a/main/nginx/nginx.initd b/main/nginx/nginx.initd
new file mode 100644
index 0000000000..992d5fd5b9
--- /dev/null
+++ b/main/nginx/nginx.initd
@@ -0,0 +1,66 @@
+#!/sbin/openrc-run
+
+description="Nginx http and reverse proxy server"
+extra_started_commands="reload reopen upgrade"
+
+cfgfile=${cfgfile:-/etc/nginx/nginx.conf}
+pidfile=/run/nginx/nginx.pid
+command=/usr/sbin/nginx
+command_args="-c $cfgfile"
+required_files="$cfgfile"
+
+depend() {
+ need net
+ use dns logger netmount
+}
+
+start_pre() {
+ ebegin
+ checkpath --directory --owner nginx:nginx ${pidfile%/*}
+ $command $command_args -t -q
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${SVCNAME} configuration"
+ start_pre && start-stop-daemon --signal HUP --pidfile $pidfile
+ eend $?
+}
+
+reopen() {
+ ebegin "Reopening ${SVCNAME} log files"
+ start-stop-daemon --signal USR1 --pidfile $pidfile
+ eend $?
+}
+
+upgrade() {
+ start_pre || return 1
+
+ ebegin "Upgrading ${SVCNAME} binary"
+
+ einfo "Sending USR2 to old binary"
+ start-stop-daemon --signal USR2 --pidfile $pidfile
+
+ einfo "Sleeping 3 seconds before pid-files checking"
+ sleep 3
+
+ if [ ! -f $pidfile.oldbin ]; then
+ eerror "File with old pid ($pidfile.oldbin) not found"
+ return 1
+ fi
+
+ if [ ! -f $pidfile ]; then
+ eerror "New binary failed to start"
+ return 1
+ fi
+
+ einfo "Sleeping 3 seconds before WINCH"
+ sleep 3 ; start-stop-daemon --signal 28 --pidfile $pidfile.oldbin
+
+ einfo "Sending QUIT to old binary"
+ start-stop-daemon --signal QUIT --pidfile $pidfile.oldbin
+
+ einfo "Upgrade completed"
+
+ eend $? "Upgrade failed"
+}