Issue with systemd and nginx not starting at boot

46 views
Skip to first unread message

Patrick Heppler

unread,
Jul 28, 2014, 4:32:45 AM7/28/14
to cento...@googlegroups.com
Hi,
I'm running a centos 7 box with selfcompiled nginx 1.7.3
My systemd unit file:

[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target
After=network-online.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

However, after reboot nginx doesn't start:
Jul 28 10:11:11 localhost nginx[662]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jul 28 10:11:11 localhost nginx[662]: nginx: [emerg] bind() to 192.168.1.2:80 failed (99: Cannot assign requested address)
Jul 28 10:11:11 localhost nginx[662]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 28 10:11:11 localhost systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 28 10:11:11 localhost systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jul 28 10:11:11 localhost systemd[1]: Unit nginx.service entered failed state.

But I can manualy start it using systemctl start nginx. Seems systemd fires nginx before network is up.

Ninja Ninja

unread,
May 8, 2015, 4:38:16 AM5/8/15
to cento...@googlegroups.com
Hello

I  have the  same  problem. Do  you  know  how  to  fix it ? 

Thank  you.

FractalizeR

unread,
May 8, 2015, 5:01:46 AM5/8/15
to cento...@googlegroups.com, shtal...@gmail.com
Ensure your systemd file requires network startup:

[vagrant@localhost ~]$ cat /lib/systemd/system/nginx.service 
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target




пятница, 8 мая 2015 г., 11:38:16 UTC+3 пользователь Ninja Ninja написал:

Ninja Ninja

unread,
May 8, 2015, 6:12:39 AM5/8/15
to cento...@googlegroups.com, shtal...@gmail.com
yes,  all  is  good in  systemd  config

[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target


i  have   changed temporally in  nginx  config  IP  address  to  0.0.0.0  and  the  problem    resolved  temporally. But  i  can't  understand  why nginx   doesn't  start  on  boot  and  it    easy  starts  manualy 
Thank you  for your  answer.

Vladislav Rastrusny

unread,
May 9, 2015, 3:03:30 AM5/9/15
to cento...@googlegroups.com
I would say, that your network adapter for 192.168.x.x network starts
up not by systemd, but by some other script. You need to locate it in
the system.

----------------------------------
Best regards,
Vladislav "FractalizeR" Rastrusny
http://www.fractalizer.ru
Fract...@yandex.ru
> --
> You received this message because you are subscribed to the Google Groups
> "CentOS Linux for System Administrators Discussion Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to centos-adm+...@googlegroups.com.
> To post to this group, send email to cento...@googlegroups.com.
> Visit this group at http://groups.google.com/group/centos-adm.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages