Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jul 2008 13:40:39 +0400 (MSD)
From:      Maxim Dounin <mdounin@mdounin.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/125766: [patch] www/nginx-devel - extra command: upgrade
Message-ID:  <20080719094039.3D74517051@mdounin.cust.ramtel.ru>
Resent-Message-ID: <200807190950.m6J9o272097653@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         125766
>Category:       ports
>Synopsis:       [patch] www/nginx-devel - extra command: upgrade
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 19 09:50:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Maxim Dounin
>Release:        FreeBSD 7.0-RC2 i386
>Organization:
>Environment:
System: FreeBSD mdounin.cust.ramtel.ru 7.0-RC2 FreeBSD 7.0-RC2 #1: Mon Feb 18 19:55:43 MSK 2008 root@mdounin.cust.ramtel.ru:/usr/obj/usr/src/sys/GENERIC i386
>Description:

Extra command to rc script: upgrade.

Runs simple form of nginx binary upgrade procedure, allowing to change binary
on-the-fly without loosing any single request.

>How-To-Repeat:
>Fix:

# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1216436541 -14400
# Node ID 8d0ab4f3900bb4e6fdb22564ff2b33ee2f49e33a
# Parent  695fa767cf2984222d07b57f288c27f1d54c9706
Extra command: upgrade.

Runs simple form of nginx binary upgrade procedure, allowing to change binary
on-the-fly without loosing any single request.

diff --git a/files/nginx.sh.in b/files/nginx.sh.in
--- a/files/nginx.sh.in
+++ b/files/nginx.sh.in
@@ -28,6 +28,8 @@ restart_precmd="nginx_checkconfig"
 restart_precmd="nginx_checkconfig"
 reload_precmd="nginx_checkconfig"
 configtest_cmd="nginx_checkconfig"
+upgrade_precmd="nginx_checkconfig"
+upgrade_cmd="nginx_upgrade"
 command="%%PREFIX%%/sbin/nginx"
 _pidprefix="/var/run/nginx"
 pidfile="${_pidprefix}.pid"
@@ -89,6 +91,23 @@ nginx_checkconfig()
 	eval ${command} ${nginx_flags} -t
 }
 
+nginx_upgrade()
+{
+	echo "Upgrading nginx binary:"
+
+	reload_precmd=""
+	sig_reload="USR2"
+	run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
+
+	sleep 1
+
+	echo "Stopping old binary:"
+
+	sig_reload="QUIT"
+	pidfile="$pidfile.oldbin"
+	run_rc_command ${rc_prefix}reload $rc_extra_args || return 1
+}
+
 nginx_precmd() 
 {
 	nginx_checkconfig
@@ -102,5 +121,5 @@ nginx_precmd()
 
 }
 
-extra_commands="reload configtest"
+extra_commands="reload configtest upgrade"
 run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080719094039.3D74517051>