From owner-freebsd-ports@FreeBSD.ORG Tue Jul 19 17:10:49 2011 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A810E106566B for ; Tue, 19 Jul 2011 17:10:49 +0000 (UTC) (envelope-from feld@feld.me) Received: from mwi1.coffeenet.org (unknown [IPv6:2607:f4e0:100:300::2]) by mx1.freebsd.org (Postfix) with ESMTP id 73C0E8FC0A for ; Tue, 19 Jul 2011 17:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=feld.me; s=blargle; h=Message-Id:From:Mime-Version:Date:Subject:To:Content-Type; bh=cDPBZ+zRtVfV+mK8+N2AJP2CPKwGIsISbEcXymsCya0=; b=pUSheoPLZgV6kDYsgM5wa2i/jA8CVtC9paF4al5tw+zHERzGC/+e4DOjgbNY/tvF2xnOrYzeE9j88LWB7XDF4HfoGdHaojli+dejRjTljqkgEVyB+NwoZUYZkWlZHWep; Received: from localhost ([127.0.0.1] helo=mwi1.coffeenet.org) by mwi1.coffeenet.org with esmtp (Exim 4.76 (FreeBSD)) (envelope-from ) id 1QjDrK-0007LH-BW for freebsd-ports@freebsd.org; Tue, 19 Jul 2011 12:13:27 -0500 Received: from feld@feld.me by mwi1.coffeenet.org (Archiveopteryx 3.1.4) with esmtpsa id 1311095600-19537-19534/5/3; Tue, 19 Jul 2011 17:13:20 +0000 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: freebsd-ports@freebsd.org Date: Tue, 19 Jul 2011 12:10:40 -0500 Mime-Version: 1.0 From: Mark Felder Message-Id: User-Agent: Opera Mail/12.00 (FreeBSD) X-SA-Score: -1.0 Subject: net/haproxy doesn't stop all processes X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2011 17:10:49 -0000 Hi all, I recently installed haproxy and I am in the process of configuring redundant load balancers and I discovered a bug in the haproxy shutdown sequence. For some reason the first PID in /var/run/haproxy is the only one that gets a kill signal when you shutdown. In order to reproduce this behavior you will have to increase the number of haproxy processes with the following setting: nbproc 4 # Number of processes I can get it to kill cleanly from the shell but when I modify the pre_stop() it still doesn't work. Any thoughts? Current rc script for those who don't have it installed is below. Regards, Mark #!/bin/sh # PROVIDE: haproxy # REQUIRE: DAEMON # KEYWORD: shutdown ####### # # Add the following lines to /etc/rc.conf to enable haproxy: # # haproxy_enable (bool): default: "NO" # Set to "YES" to enable haproxy # haproxy_pidfile (str): default: /var/run/${name}.pid # Set to the full path of the pid file # haproxy_config (str): default: /usr/local/etc/${name}.conf # Set to the full path of the config file # haproxy_flags (str): default: Autogenerated using pidfile and config options # Set to override with your own options # ####### # # rc.d Script Runtime Options: # # start - starts application normally # stop - (softstop) stops all proxies and exits once all sessions are closed # forcestop - (immediate) stops all proxies and kills active sessions # reload - hot-reconfig using "-sf" option (active sessions kept) # forcereload - hot-reconfig using "-st" option (active sessions killed) # restart - equiv to "stop" then "start" # checkconfig - checks configuration file defined in haproxy_config # ####### . /etc/rc.subr name="haproxy" rcvar=`set_rcvar` command="/usr/local/sbin/haproxy" # Load Configs/Set Defaults load_rc_config $name : ${haproxy_enable:="NO"} : ${haproxy_config:="/usr/local/etc/${name}.conf"} : ${haproxy_pidfile:="/var/run/${name}.pid"} : ${haproxy_flags="-q -f ${haproxy_config} -p ${haproxy_pidfile}"} # Update the globals pidfile=${haproxy_pidfile} required_files=${haproxy_config} # Commands: start, stop, restart, reload, checkconfig extra_commands="reload checkconfig" checkconfig_cmd="haproxy_checkconfig" reload_cmd="haproxy_reload" haproxy_reload() { # Check configuration file quietly first ${command} -q -c -f ${haproxy_config} if [ $? -ne 0 ]; then echo "Error found in ${haproxy_config} - not reloading current process!" return fi rc_pid=$(check_pidfile ${haproxy_pidfile} ${command}) if [ $rc_pid ]; then if [ $rc_force ]; then ${command} ${haproxy_flags} -st ${rc_pid} else ${command} ${haproxy_flags} -sf ${rc_pid} fi else echo "No process found. Maybe $command isn't running?" fi } haproxy_checkconfig() { ${command} -c -f ${haproxy_config} } haproxy_prestart() { ${command} -q -c -f ${haproxy_config} rc_flags=${haproxy_flags} } haproxy_prestop() { # SIGUSR1 = softstop, SIGTERM = faststop if [ $rc_force ]; then sig_stop="SIGTERM" else sig_stop="SIGUSR1" fi } run_rc_command "$1"