[packages/nginx] add reopen-logs target

glen glen at pld-linux.org
Sun May 3 22:38:26 CEST 2015


commit f80bc012905a4e9a4a8b7c2be33e174cd4b1fc0c
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun May 3 23:37:24 2015 +0300

    add reopen-logs target
    
    do not reload config just to rotate logs!

 nginx.init      | 13 ++++++++++++-
 nginx.logrotate |  8 ++++----
 2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/nginx.init b/nginx.init
index 16da7a9..10e1779 100755
--- a/nginx.init
+++ b/nginx.init
@@ -143,6 +143,14 @@ upgrade() {
 	fi
 }
 
+# Tell nginx to reopen logs
+# http://nginx.org/en/docs/control.html#logs
+reopen_logs() {
+	checkconfig
+	show "Reopening $svname logs"
+	killproc -p $pidfile $prog -USR1
+}
+
 RETVAL=0
 # See how we were called.
 case "$1" in
@@ -166,6 +174,9 @@ case "$1" in
   force-reload|upgrade) 
 	upgrade
 	;;
+  reopen-logs)
+	reopen_logs
+	;;
   checkconfig|configtest)
 	checkconfig 1
 	;;
@@ -174,7 +185,7 @@ case "$1" in
 	RETVAL=$?
 	;;
   *)
-	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|checkconfig|status}"
+	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|reopen-logs|checkconfig|status}"
 	exit 3
 	;;
 esac
diff --git a/nginx.logrotate b/nginx.logrotate
index de1f30d..c1404da 100644
--- a/nginx.logrotate
+++ b/nginx.logrotate
@@ -4,16 +4,16 @@
 	sharedscripts
 	postrotate
 		if [ -x /etc/rc.d/init.d/nginx-light ] ; then
-			/sbin/service nginx-light graceful > /dev/null
+			/sbin/service nginx-light reopen-logs > /dev/null
 		fi
 		if [ -x /etc/rc.d/init.d/nginx-standard ] ; then
-			/sbin/service nginx-standard graceful > /dev/null
+			/sbin/service nginx-standard reopen-logs > /dev/null
 		fi
 		if [ -x /etc/rc.d/init.d/nginx-mail ] ; then
-			/sbin/service nginx-mail graceful > /dev/null
+			/sbin/service nginx-mail reopen-logs > /dev/null
 		fi
 		if [ -x /etc/rc.d/init.d/nginx-perl ] ; then
-			/sbin/service nginx-perl graceful > /dev/null
+			/sbin/service nginx-perl reopen-logs > /dev/null
 		fi
 	endscript
 }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/nginx.git/commitdiff/136ef200866e2d1972433b95e306f0fe978e4e5f



More information about the pld-cvs-commit mailing list