nginx/1.4.6 on 14.04 LTS x86_64, init.d script does not have proper error handling

Bug #1494183 reported by Radoslav Stefanov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
New
Undecided
Unassigned

Bug Description

If for some reason Nginx can not start, the init.d script does not detect a problem.

=============================================================
root@vm-web1-qa4:~# su web
web@vm-web1-qa4:/root$ service nginx start
web@vm-web1-qa4:/root$ echo $?
0
web@vm-web1-qa4:/root$ ps aux | grep -v grep | grep nginx
=============================================================

Bellow I have removed /dev/null redirect to make it a bit noisy (why redirect to /dev/null in the first place?)
=============================================================
root@vm-web1-qa4:~# service nginx start
nginx: [emerg] open() "/var/log/nginx/domain.com/access.log" failed (2: No such file or directory)
root@vm-web1-qa4:~# echo $?
0
=============================================================

=============================================================
root@vm-web1-qa4:~# /etc/init.d/nginx start
nginx: [emerg] open() "/var/log/nginx/domain.com/access.log" failed (2: No such file or directory)
root@vm-web1-qa4:~# echo $?
0
=============================================================

In the example above I have moved /var/log/domain.com directory to /var/log/domain.com.bk directory [ to break Nginx ] and the init.d script does not report any error. Instead it just returns 0 for success.

This breaks a lot of scripts that depend on return codes. When there is a problem and Nginx has not started for whatever reason, the /etc/init.d/nginx should be able to detect it and print appropriate error code.

Ubuntu 14.04 LTS 64 bit
Nginx 1.4.6

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.