Warning at systemd restart

Hi, first of greetings to the beautiful people at HAProxy Forums. I am in dire need of help.

I have recently installed HAProxy 2.1.4 with LUA 5.3.5 on my CentOS server on linux 3.10.0-1062.el7.x86_64.

Here are my make arguments:

make USE_NS=1 USE_TFO=1 USE_OPENSSL=1 USE_ZLIB=1 USE_LUA=1 USE_PCRE=1 USE_SYSTEMD=1 USE_LIBCRYPT=1 USE_THREAD=1 TARGET=linux-glibc LUA_INC=/opt/lua-5.3.5/include LUA_LIB=/opt/lua-5.3.5/lib

Here is output from haproxy -vv:
[root@localhost haproxy-2.1.4]# haproxy -vv
HA-Proxy version 2.1.4 2020/04/02 - https://haproxy.org/
Status: stable branch - will stop receiving fixes around Q1 2021.
Known bugs: http://www.haproxy.org/bugs/bugs-2.1.4.html
Build options :
TARGET = linux-glibc
CPU = generic
CC = gcc
CFLAGS = -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-old-style-declaration -Wno-ignored-qualifiers -Wno-clobbered -Wno-missing-field-initializers -Wtype-limits
OPTIONS = USE_PCRE=1 USE_THREAD=1 USE_LIBCRYPT=1 USE_OPENSSL=1 USE_LUA=1 USE_ZLIB=1 USE_TFO=1 USE_NS=1 USE_SYSTEMD=1

Feature list : +EPOLL -KQUEUE -MY_EPOLL -MY_SPLICE +NETFILTER +PCRE -PCRE_JIT -PCRE2 -PCRE2_JIT +POLL -PRIVATE_CACHE +THREAD -PTHREAD_PSHARED -REGPARM -STATIC_PCRE -STATIC_PCRE2 +TPROXY +LINUX_TPROXY +LINUX_SPLICE +LIBCRYPT +CRYPT_H -VSYSCALL +GETADDRINFO +OPENSSL +LUA +FUTEX +ACCEPT4 -MY_ACCEPT4 +ZLIB -SLZ +CPU_AFFINITY +TFO +NS +DL +RT -DEVICEATLAS -51DEGREES -WURFL +SYSTEMD -OBSOLETE_LINKER +PRCTL +THREAD_DUMP -EVPORTS

Default settings :
  bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Built with multi-threading support (MAX_THREADS=64, default=1).
Built with OpenSSL version : OpenSSL 1.0.2k-fips  26 Jan 2017
Running on OpenSSL version : OpenSSL 1.0.2k-fips  26 Jan 2017
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : SSLv3 TLSv1.0 TLSv1.1 TLSv1.2
Built with Lua version : Lua 5.3.5
Built with network namespace support.
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Built with PCRE version : 8.32 2012-11-30
Running on PCRE version : 8.32 2012-11-30
PCRE library supports JIT : no (USE_PCRE_JIT not set)
Encrypted password support via crypt(3): yes
Built with zlib version : 1.2.7
Running on zlib version : 1.2.7
Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")

Available polling systems :
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 3 (3 usable), will use epoll.

Available multiplexer protocols :
(protocols marked as <default> cannot be specified using 'proto' keyword)
              h2 : mode=HTTP       side=FE|BE     mux=H2
            fcgi : mode=HTTP       side=BE        mux=FCGI
       <default> : mode=HTTP       side=FE|BE     mux=H1
       <default> : mode=TCP        side=FE|BE     mux=PASS

Available services : none

Available filters :
        [SPOE] spoe
        [CACHE] cache
        [FCGI] fcgi-app
        [TRACE] trace
        [COMP] compression

Then what I have done is the following:
mkdir -p /etc/haproxy
mkdir -p /var/lib/haproxy
touch /var/lib/haproxy/stats
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
cp examples/haproxy.init /etc/init.d/haproxy
chmod 755 /etc/init.d/haproxy
systemctl daemon-reload
chkconfig haproxy on
useradd -r haproxy

When i start and stop via systemctl however, everything just works fine except for in the logs i get this: /etc/rc.d/init.d/haproxy: line 26: [: =: unary operator expected
Here is the full output:
**[root@localhost haproxy-2.1.4]# systemctl status haproxy
● haproxy.service - SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.
Loaded: loaded (/etc/rc.d/init.d/haproxy; bad; vendor preset: disabled)
Active: active (running) since Fri 2020-04-24 16:32:51 IST; 9min ago
Docs: man:systemd-sysv-generator(8)
Process: 2028 ExecStop=/etc/rc.d/init.d/haproxy stop (code=exited, status=0/SUCCESS)
Process: 2048 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=0/SUCCESS)
Main PID: 2057 (haproxy)
CGroup: /system.slice/haproxy.service
└─2057 /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid

Apr 24 16:32:51 localhost.localdomain systemd[1]: Starting SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for hi...nts....
Apr 24 16:32:51 localhost.localdomain haproxy[2048]: /etc/rc.d/init.d/haproxy: line 26: [: =: unary operator expected
Apr 24 16:32:51 localhost.localdomain haproxy[2048]: Starting haproxy: [  OK  ]
Apr 24 16:32:51 localhost.localdomain systemd[1]: Started SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for hig...ments..**

Now i can’t bang my head around as to why this line is there? Also, since it is evident that I compiled wth systemd I am aware that I have not copied the systemd service file. So when the do the following:
rm /etc/init.d/haproxy
cd contrib/systemd
cp haproxy.service.in /lib/systemd/system/
systemctl daemon-reload
systemctl enable haproxy
systemctl start haproxy
systemctl status haproxy

I land in complete soup as now systemctl restart haproxy results the below:
[root@localhost haproxy-2.1.4]# systemctl start haproxy

Failed to start haproxy.service: Unit not found.

[root@localhost haproxy-2.1.4]# systemctl status haproxy

Unit haproxy.service could not be found.

So it seems like there is a file name mismatch so i manually rename the file and then now the results are as follows:
[root@localhost haproxy-2.1.4]# mv -v /lib/systemd/system/haproxy.service.in /lib/systemd/system/haproxy.service

‘/lib/systemd/system/haproxy.service.in’ -> ‘/lib/systemd/system/haproxy.service’

[root@localhost haproxy-2.1.4]# systemctl daemon-reload

[root@localhost haproxy-2.1.4]# systemctl restart haproxy

Failed to restart haproxy.service: Unit is not loaded properly: Invalid argument.

See system logs and 'systemctl status haproxy.service' for details.

[root@localhost haproxy-2.1.4]# systemctl status haproxy.service

● haproxy.service - HAProxy Load Balancer

Loaded: error (Reason: Invalid argument)

Active: inactive (dead) since Fri 2020-04-24 16:48:03 IST; 3min 53s ago

Main PID: 2057 (code=killed, signal=TERM)

Apr 24 16:32:51 localhost.localdomain systemd[1]: Starting SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for hi...nts....

Apr 24 16:32:51 localhost.localdomain haproxy[2048]: /etc/rc.d/init.d/haproxy: line 26: [: =: unary operator expected

Apr 24 16:32:51 localhost.localdomain haproxy[2048]: Starting haproxy: [ OK ]

Apr 24 16:32:51 localhost.localdomain systemd[1]: Started SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for hig...ments..

Apr 24 16:48:03 localhost.localdomain systemd[1]: Stopping haproxy.service...

Apr 24 16:48:03 localhost.localdomain systemd[1]: Stopped haproxy.service.

Apr 24 16:51:40 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/haproxy.service:9] Executable path is not absolute, ignoring: ...TRAOPTS

Apr 24 16:51:40 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/haproxy.service:10] Executable path is not absolute, ignoring:...TRAOPTS

Apr 24 16:51:40 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/haproxy.service:11] Executable path is not absolute, ignoring:...TRAOPTS

Apr 24 16:51:40 localhost.localdomain systemd[1]: haproxy.service lacks both ExecStart= and ExecStop= setting. Refusing.

Hint: Some lines were ellipsized, use -l to show in full.

I am looking for some urgent help here. Thanks in advance.

Regards,

you can’t use haproxy.service.in as a unit file, you need to use make to build the haproxy.service file from the haproxy.service.in file.
cd $haproxy_sources/contrib/systemd && make

Works wonders. Seems like that’s all I was missing. Thanks a lot :slight_smile: