Re: -sf/-st not working

2013-02-06 Thread Willy Tarreau
Hello Eugene,

On Wed, Feb 06, 2013 at 08:29:33PM +0200, Eugene Istomin wrote:
> Hello,
> 
> We have problem with reload/HUP:
> if i run #/usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p
> /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)  - haproxy process is
> shutting down and exit

This is the intended behaviour, it unbinds from its ports so that the new
process can bind, then waits for all existing connections to terminate
and leaves. Isn't it what you're observing ? What would you have expected
instead ?

Willy




-sf/-st not working

2013-02-06 Thread Eugene Istomin
Hello,

We have problem with reload/HUP:
if i run #/usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p 
/var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)  - haproxy process is 
shutting down and exit

from strace:
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(4, SOL_SOCKET, 0xf /* SO_??? */, [1], 4) = -1 ENOPROTOOPT (Protocol 
not available)
bind(4, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 
16) = -1 EADDRINUSE (Address already in use)
close(4)= 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(4, SOL_SOCKET, 0xf /* SO_??? */, [1], 4) = -1 ENOPROTOOPT (Protocol 
not available)
bind(4, {sa_family=AF_INET, sin_port=htons(443), 
sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
close(4)= 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(4, SOL_SOCKET, 0xf /* SO_??? */, [1], 4) = -1 ENOPROTOOPT (Protocol 
not available)
setsockopt(4, SOL_TCP, TCP_DEFER_ACCEPT, [1], 4) = 0
bind(4, {sa_family=AF_INET, sin_port=htons(6000), 
sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
close(4) 

.

select(0, NULL, NULL, NULL, {0, 1}) = 0 (Timeout)
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(4, SOL_SOCKET, 0xf /* SO_??? */, [1], 4) = -1 ENOPROTOOPT (Protocol 
not available)
bind(4, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 
16) = 0
listen(4, 2000) = 0
setsockopt(4, SOL_TCP, TCP_QUICKACK, [0], 4) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 5
fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(5, SOL_SOCKET, 0xf /* SO_??? */, [1], 4) = -1 ENOPROTOOPT (Protocol 
not available)
bind(5, {sa_family=AF_INET, sin_port=htons(443), 
sin_addr=inet_addr("0.0.0.0")}, 16) = 0
listen(5, 2000)

.

rt_sigaction(SIGTTOU, {0x459110, [TTOU], SA_RESTORER|SA_RESTART, 
0x7ff38ba41da0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTTIN, {0x459110, [TTIN], SA_RESTORER|SA_RESTART, 
0x7ff38ba41da0}, {SIG_DFL, [], 0}, 8) = 0
unlink("/var/run/haproxy.pid")  = 0
open("/var/run/haproxy.pid", O_WRONLY|O_CREAT|O_TRUNC, 0644) = 11
kill(22708, SIGUSR1)= 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=40036, rlim_max=40036}) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0x7ff38cc549d0) = 22716
write(11, "22716\n", 6) = 6
close(11)   = 0
exit_group(0)   = ?
+++ exited with 0 +++


#haproxy -V
HA-Proxy version 1.5-dev17 2012/12/28

-- 
Best regards,
Eugene Istomin

Re: Backend Configuration Templating

2013-02-06 Thread Holger Just

Hi

Michael Glenney wrote:

We do something similar with chef where we've turned each backend
config associated with an application into json and can dynamically
build configs based on an application list. Completely avoiding using
a template.


In my HAProxy Chef cookbook[1], I have defined resources to generate 
sections (global, default, listen, frontend, backend) into individual 
files from custom templates. This is because I found configurations to 
be too complex to be able to transform them into a tree structure 
without loosing flexibility (and understandability).


These section files are then concatenated to a single config file during 
reload using a simple shell script[2].


Using this technique, the user of the cookbook is able to write 
customized templates which can e.g. loop over search results and 
dynamically create complete configs similar to what Robin Lee Powell showed.


Alternatively, in Chef 11 which was released about two days ago, you can 
create directly create a single config file from partial templates 
without having to first create single files.


If you don't use Chef, there are a couple of other scripts which concat 
your partial config into a full config file. One by me [3] written in 
python, and another in Ruby by Joe Williams[4]. These are intended to be 
used as part of an init script. An example can be found in the repo of [3].


--Holger

[1] https://github.com/meineerde-cookbooks/haproxy
[2] 
https://github.com/meineerde-cookbooks/haproxy/blob/master/files/default/haproxy_join 


[3] https://github.com/finnlabs/haproxy
[4] https://github.com/joewilliams/haproxy_join