mirror of
https://git.freebsd.org/ports.git
synced 2025-06-14 01:00:33 -04:00
pids to $pidfile (one pid per line). Our check_pidfile() from rc.subr will get only first pid and use it for stop/status/etc which is incorrect. Do not use pidfile for that, rather use $procname to get the list of running haproxy processes. [If you know how to do the same with pidfile, please tell me.]
84 lines
2.2 KiB
Bash
84 lines
2.2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: haproxy
|
|
# REQUIRE: DAEMON LOGIN
|
|
# 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"
|
|
# configtest - checks configuration file defined in haproxy_config
|
|
#
|
|
#######
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="haproxy"
|
|
rcvar=haproxy_enable
|
|
command="%%PREFIX%%/sbin/haproxy"
|
|
|
|
# Load Configs/Set Defaults
|
|
load_rc_config $name
|
|
: ${haproxy_enable:="NO"}
|
|
: ${haproxy_pidfile:="/var/run/haproxy.pid"}
|
|
: ${haproxy_config:="%%PREFIX%%/etc/${name}.conf"}
|
|
: ${haproxy_flags="-q -f ${haproxy_config} -p ${haproxy_pidfile}"}
|
|
procname=${command}
|
|
|
|
# Update the globals
|
|
required_files=$haproxy_config
|
|
|
|
# Commands: start, stop, restart, reload, configtest
|
|
extra_commands="reload configtest"
|
|
|
|
configtest_cmd="$command -c -f $haproxy_config"
|
|
start_precmd="$command -q -c -f $haproxy_config"
|
|
reload_cmd="haproxy_reload"
|
|
|
|
# For stopping, SIGUSR1 = softstop, SIGTERM = faststop
|
|
sig_stop=${rc_force:-USR1}
|
|
|
|
haproxy_reload()
|
|
{
|
|
# Check configuration file quietly first
|
|
${command} -q -c -f ${haproxy_config}
|
|
if [ $? -ne 0 ]; then
|
|
err 1 "Error found in ${haproxy_config} - not reloading current process!"
|
|
fi
|
|
rc_pid=$(check_process ${procname})
|
|
if [ -n "$rc_pid" ]; then
|
|
if [ $rc_force ]; then
|
|
${command} ${haproxy_flags} -st ${rc_pid}
|
|
else
|
|
${command} ${haproxy_flags} -sf ${rc_pid}
|
|
fi
|
|
else
|
|
_run_rc_notrunning
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
run_rc_command "$1"
|