haproxy - How can I have a custom restart script for runit? -
i'm using runit manage haproxy , want safe restart reload configuration file (specifically: haproxy -f /etc/haproxy/haproxy.cfg -sf $old_process_id
). figure run sv restart haproxy
, tried add custom script named /etc/service/haproxy/restart
, never seems execute. how have special restart script? approach here? how reload config minimal impact using runit?
haproxy runit service script
/etc/service/haproxy/run
#!/bin/sh # # runit haproxy # # forward stderr stdout use runit svlogd exec 2>&1 pid_path=/var/run/haproxy/haproxy.pid bin_path=/opt/haproxy/sbin/haproxy cfg_path=/opt/haproxy/etc/haproxy.cfg exec /bin/bash <<eof $bin_path -f $cfg_path -d -p $pid_path trap "echo sighup caught; $bin_path -f $cfg_path -d -p $pid_path -sf \\\$(cat $pid_path)" sighup trap "echo sigterm caught; kill -term \\\$(cat $pid_path) && exit 0" sigterm sigint while true; # iterate keep job running. sleep 1 # wake handle signals done eof
graceful reload keeps things , running.
sv reload haproxy
full stop , start.
sv restart haproxy
this solution inspired https://gist.github.com/gfrey/8472007
Comments
Post a Comment