diff options
author | Kiyoshi Aman <kiyoshi.aman+adelie@gmail.com> | 2019-03-29 01:50:11 -0500 |
---|---|---|
committer | Zach van Rijn <me@zv.io> | 2022-11-02 15:57:27 -0500 |
commit | bb7e8ce936e70452b4b2a6e0661f9a64baf4de9e (patch) | |
tree | f0bc74d0412f10d6467489b421a496c03c817a14 /user/nginx/nginx.initd | |
parent | 96a94ff5f1e7c582fd58d5225ffcd22524926ade (diff) | |
download | packages-bb7e8ce936e70452b4b2a6e0661f9a64baf4de9e.tar.gz packages-bb7e8ce936e70452b4b2a6e0661f9a64baf4de9e.tar.bz2 packages-bb7e8ce936e70452b4b2a6e0661f9a64baf4de9e.tar.xz packages-bb7e8ce936e70452b4b2a6e0661f9a64baf4de9e.zip |
user/nginx: new packagenginx
Diffstat (limited to 'user/nginx/nginx.initd')
-rw-r--r-- | user/nginx/nginx.initd | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/user/nginx/nginx.initd b/user/nginx/nginx.initd new file mode 100644 index 000000000..603f91e63 --- /dev/null +++ b/user/nginx/nginx.initd @@ -0,0 +1,71 @@ +#!/sbin/openrc-run + +description="Nginx http and reverse proxy server" +extra_commands="checkconfig" +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() { + checkpath --directory --owner nginx:nginx ${pidfile%/*} + $command $command_args -t -q +} + +checkconfig() { + ebegin "Checking $RC_SVCNAME configuration" + start_pre + eend $? +} + +reload() { + ebegin "Reloading $RC_SVCNAME configuration" + start_pre && start-stop-daemon --signal HUP --pidfile $pidfile + eend $? +} + +reopen() { + ebegin "Reopening $RC_SVCNAME log files" + start-stop-daemon --signal USR1 --pidfile $pidfile + eend $? +} + +upgrade() { + start_pre || return 1 + + ebegin "Upgrading $RC_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" +} |