Hello Willy,

I modified the haproxy-systemd-wrapper with the attached patch and it
works ok from the terminal:

# /usr/local/sbin/haproxy-systemd-wrapper -p /run/haproxy.pid
-- /etc/haproxy/*
<7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -Ds
-p /run/haproxy.pid -- /etc/haproxy/haproxy.conf /etc/haproxy/z.conf 


But the systemd execution is still a issue with the following unit:



[Unit]
Description=HAProxy Load Balancer
After=network.target

[Service]
ExecStartPre=/usr/local/sbin/haproxy -c -q -- /etc/haproxy/*
ExecStart=/usr/local/sbin/haproxy-systemd-wrapper -p /run/haproxy.pid
-- /etc/haproxy/*
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Restart=always

[Install]
WantedBy=multi-user.target






● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/etc/systemd/system/haproxy.service; enabled)
   Active: failed (Result: start-limit) since Mon 2016-12-12 12:28:45
CET; 2s ago
  Process: 5896 ExecStartPre=/usr/local/sbin/haproxy -c -q
-- /etc/haproxy/* (code=exited, status=1/FAILURE)
 Main PID: 5858 (code=exited, status=0/SUCCESS)

Dec 12 12:28:45 balback1b.pre.es.sys.idealista systemd[1]:
haproxy.service: control process exited, code=exited status=1
Dec 12 12:28:45 balback1b.pre.es.sys.idealista systemd[1]: Failed to
start HAProxy Load Balancer.
Dec 12 12:28:45 balback1b.pre.es.sys.idealista systemd[1]: Unit
haproxy.service entered failed state.
Dec 12 12:28:45 balback1b.pre.es.sys.idealista systemd[1]:
haproxy.service start request repeated too quickly, refusing...art.
Dec 12 12:28:45 balback1b.pre.es.sys.idealista systemd[1]: Failed to
start HAProxy Load Balancer.
Dec 12 12:28:45 balback1b.pre.es.sys.idealista systemd[1]: Unit
haproxy.service entered failed state.



Executing the same process that return the error from the terminal
report 
/usr/local/sbin/haproxy -c -q -- /etc/haproxy/*
echo $?
0



I continue looking for the problem, but now, I think that it's close to
the systemd side.


Thanks,





El lun, 05-12-2016 a las 19:40 +0100, Willy Tarreau escribió:
> Hi Ricardo,
> 
> On Mon, Dec 05, 2016 at 11:55:44AM +0000, Ricardo Fraile wrote:
> > Hello,
> > 
> > Finally I found a workaround. Generate a list with all the configuration
> > files with a script in a ExecStartPre unit option, load the list into a
> > enviroment variable and pass them to the haproxy executable. I tried to 
> > avoid
> > the use of a external script, but due the particularities of systemd I
> > couldn't make it to work.
> 
> (...)
> 
> I *think* that the problem you describe is in fact more related to the
> systemd wrapper itself, am I wrong ? Maybe we need to modify it to
> pass -Ds first
> 
> > 2.- Create a small script into "/usr/local/bin/haproxy-multiconf" with this 
> > content:
> > 
> > #!/bin/bash
> > 
> > for file in /etc/haproxy/*.conf; do
> >         test -f $file
> >         CNF="$CNF -f $file"
> > done
> > 
> > echo "CONF='$CNF'" > /etc/haproxy/haproxy-multiconf.lst
> 
> Does systemd support bash-like pattern substitution ? In this case, you
> could use something like ${CONF[@]/#/-f } to prepend "-f" in front of
> each file.
> 
> Regards,
> Willy

From f6d0203e8dbf0046203bd105513dd8b55719be63 Mon Sep 17 00:00:00 2001
From: rfraile <[email protected]>
Date: Mon, 12 Dec 2016 12:40:11 +0100
Subject: [PATCH] Fix systemd-wrapper issue with multiconf argument

---
 src/haproxy-systemd-wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index f6a9c85..2616e2f 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -114,9 +114,9 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
 
 		locate_haproxy(haproxy_bin, 512);
 		argv[argno++] = haproxy_bin;
+		argv[argno++] = "-Ds";
 		for (i = 0; i < main_argc; ++i)
 			argv[argno++] = main_argv[i];
-		argv[argno++] = "-Ds";
 		if (nb_pid > 0) {
 			argv[argno++] = "-sf";
 			for (i = 0; i < nb_pid; ++i)
-- 
2.1.4

Reply via email to