Hi Jarno,
Yes, shell expansion did the trick, this is the working systemd unit:
[Unit]
Description=HAProxy Load Balancer
After=network.target
[Service]
ExecStartPre=/bin/sh -c "/usr/local/sbin/haproxy -c -q
-- /etc/haproxy/*"
ExecStart=/bin/sh -c "/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
I didn't know the new behavior of "-f" in v.1.7, that fit better with
the bash pattern substitution in proposed by Willy ${CONF[@]/#/-f }
Thanks,
El lun, 12-12-2016 a las 16:28 +0200, Jarno Huuskonen escribió:
> Hi,
>
> On Mon, Dec 12, Ricardo Fraile wrote:
> > 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
>
> [...]
>
> >
> > Executing the same process that return the error from the terminal
> > report
> > /usr/local/sbin/haproxy -c -q -- /etc/haproxy/*
> > echo $?
> > 0
>
> I think systemd doesn't do shell expansion on "/etc/haproxy/*". Does
> it work from terminal if you run:
> /usr/local/sbin/haproxy -c -q -- '/etc/haproxy/*' ; echo $?
> (single quotes around '/etc/haproxy/*') ?
>
> Have you tried with haproxy 1.7 ? With 1.7:
> " - support of directories for config files : now if the argument to -f
> is a directory, all files found there are loaded in alphabetical
> order. Additionally, files can be specified after "--" without having
> to repeat "-f".
> "
>
> Or you could try to use something like
> /bin/sh -c "/usr/local/sbin/haproxy -c -q -- /etc/haproxy/*" as the
> ExecStartPre/ExecStart command. (This might leave extra /bin/sh
> process ...)
>
> -Jarno
>