Workaround of race condition between systemd and nginx.
Gena Makhomed
gmm at csdoc.com
Wed Dec 30 15:50:44 UTC 2015
On 30.12.2015 16:51, Jim Popovitch wrote:
>> # HG changeset patch
>> # User Gena Makhomed <gmm at csdoc.com>
>> # Date 1451482795 18000
>> # Wed Dec 30 08:39:55 2015 -0500
>> # Node ID a340d271b3ffa51c0396a5afc5270cb02b701204
>> # Parent 1073d7e4e430ddb53b603d151e1a403d10aa420b
>> Workaround of race condition between systemd and nginx.
>>
>> Just replace network.target with network-online.target in systemd unit
> files.
>> More details:
> http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
>
>>From that page, wrt network-online.target:
>
> "It is strongly recommended not to pull in this target too liberally: for
> example network server software should generally not pull this in (since
> server software generally is happy to accept local connections even before
> any routable network interface is up), it's primary purpose is network
> client software that cannot operate without network"
nginx is FreeBSD daemon, ant it is not systemd-aware,
and nginx not follow many strange systemd guidelines.
Current race condition between systemd and nginx follow
to non-working nginx daemon at least under CentOS 7.2
templates under OpenVZ after system reboot.
nginx now requires configured and up network, before starting daemon.
Replace network.target with network-online.target is easy workaround.
P.S.
# cat /var/log/messages
Dec 27 19:08:38 stage-ideil-com systemd: Starting nginx - high
performance web server...
Dec 27 19:08:39 stage-ideil-com systemd: Starting System Logging Service...
Dec 27 19:08:39 stage-ideil-com systemd: Starting LSB: Bring up/down
networking...
Dec 27 19:08:39 stage-ideil-com systemd: Starting Postfix Mail Transport
Agent...
[...]
Dec 27 19:09:24 stage-ideil-com systemd: nginx.service: control process
exited, code=exited status=1
Dec 27 19:09:24 stage-ideil-com systemd: Failed to start nginx - high
performance web server.
Dec 27 19:09:24 stage-ideil-com systemd: Unit nginx.service entered
failed state.
Dec 27 19:09:24 stage-ideil-com systemd: nginx.service failed.
Dec 27 19:09:24 stage-ideil-com systemd-sysctl: Failed to write '16' to
'/proc/sys/kernel/sysrq': Permission denied
Dec 27 19:09:24 stage-ideil-com systemd-sysctl: Failed to write '1' to
'/proc/sys/kernel/core_uses_pid': Permission denied
>Dec 27 19:09:24 stage-ideil-com systemd: Started LSB: Bring up/down
networking.
>Dec 27 19:09:24 stage-ideil-com systemd: Reached target Network is Online.
>Dec 27 19:09:24 stage-ideil-com systemd: Starting Network is Online.
Dec 27 19:09:24 stage-ideil-com systemd: Started The PHP FastCGI Process
Manager.
>Dec 27 19:09:24 stage-ideil-com nginx: nginx: the configuration file
/etc/nginx/nginx.conf syntax is ok
>Dec 27 19:09:24 stage-ideil-com nginx: nginx: [emerg] bind() to
172.22.22.202:80 failed (99: Cannot assign requested address)
>Dec 27 19:09:24 stage-ideil-com nginx: nginx: configuration file
/etc/nginx/nginx.conf test failed
>Dec 27 19:09:24 stage-ideil-com network: Bringing up loopback
interface: [ OK ]
>Dec 27 19:09:25 stage-ideil-com network: Bringing up interface venet0:
arping: Device venet0 not available.
>Dec 27 19:09:25 stage-ideil-com network: [ OK ]
=====================================================================
# cat /var/log/messages
Dec 24 18:55:14 hroniky-com systemd: Starting Sockets.
Dec 24 18:55:14 hroniky-com systemd: Reached target Basic System.
Dec 24 18:55:14 hroniky-com systemd: Starting Basic System.
Dec 24 18:55:14 hroniky-com systemd: Started D-Bus System Message Bus.
Dec 24 18:55:14 hroniky-com systemd: Starting D-Bus System Message Bus...
Dec 24 18:55:14 hroniky-com systemd: Starting Permit User Sessions...
Dec 24 18:55:14 hroniky-com systemd: Starting Postfix Mail Transport
Agent...
Dec 24 18:55:14 hroniky-com systemd: Started OpenSSH Server Key Generation.
Dec 24 18:55:14 hroniky-com systemd: Starting /etc/rc.d/rc.local
Compatibility...
Dec 24 18:55:15 hroniky-com systemd: Starting nginx - high performance
web server...
Dec 24 18:55:18 hroniky-com systemd: Starting System Logging Service...
Dec 24 18:55:18 hroniky-com systemd: Starting LSB: Bring up/down
networking...
Dec 24 18:55:18 hroniky-com nginx: nginx: the configuration file
/etc/nginx/nginx.conf syntax is ok
Dec 24 18:55:18 hroniky-com nginx: nginx: [emerg] bind() to
172.23.23.161:80 failed (99: Cannot assign requested address)
Dec 24 18:55:18 hroniky-com nginx: nginx: configuration file
/etc/nginx/nginx.conf test failed
Dec 24 18:55:18 hroniky-com systemd: Starting The PHP FastCGI Process
Manager...
Dec 24 18:55:18 hroniky-com systemd: Started OpenSSH server daemon.
Dec 24 18:55:18 hroniky-com systemd: Starting OpenSSH server daemon...
Dec 24 18:55:18 hroniky-com systemd: Starting Login Service...
Dec 24 18:55:18 hroniky-com systemd: Starting Dump dmesg to
/var/log/dmesg...
Dec 24 18:55:18 hroniky-com systemd: Started Permit User Sessions.
Dec 24 18:55:18 hroniky-com systemd: Started /etc/rc.d/rc.local
Compatibility.
Dec 24 18:55:18 hroniky-com systemd: nginx.service: control process
exited, code=exited status=1
Dec 24 18:55:18 hroniky-com systemd: Failed to start nginx - high
performance web server.
Dec 24 18:55:18 hroniky-com systemd: Unit nginx.service entered failed
state.
Dec 24 18:55:18 hroniky-com systemd: nginx.service failed.
--
Best regards,
Gena
More information about the nginx-devel
mailing list