Comment 0 for bug 1314740

Revision history for this message
Scott Hollenbeck (g-sah) wrote : awk in startup script finds wrong pid

After upgrading a server from 12.04 to 14.04 I found that the nginx web server wasn't starting automatically. I could start the server without error from the command line. Running "sudo /etc/init.d/nginx start" would produce no visible error, but the service would not be started. Running "sudo /etc/init.d/nginx restart" produces a visible "fail" error.

The nginx startup script (/etc/init.d/nginx) includes this line:

PID=$(awk -F'[ \t;]+' '/[^#]pid/ {print $2}' /etc/nginx/nginx.conf)

This is intended to find this line (or similar) in the nginx.conf file:

pid /var/run/nginx.pid;

My nginx.conf file includes this map directive:

map $http_user_agent $is_bot {
                default 0;
                ~*(crawl|Google|Slurp|bingbot|tracker|click|parser|spider|msnbot|Gigabot) 1;
 }

The issue is that awk returns the line that includes "spider", which creates an incorrect value for the location of the pid file, and the startup script fails. The version of /etc/init.d/nginx provided with 12.04 did not inlcude this awk command and the startup script worked without error.

$ lsb_release -rd
Description: Ubuntu 14.04 LTS
Release: 14.04

$ sudo nginx -v
nginx version: nginx/1.4.6 (Ubuntu)
$

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: nginx 1.4.6-1ubuntu3
ProcVersionSignature: Ubuntu 3.13.0-24.46-generic 3.13.9
Uname: Linux 3.13.0-24-generic x86_64
ApportVersion: 2.14.1-0ubuntu3
Architecture: amd64
Date: Wed Apr 30 13:30:35 2014
Dependencies:

InstallationDate: Installed on 2014-01-30 (90 days ago)
InstallationMedia: Ubuntu-Server 12.04.3 LTS "Precise Pangolin" - Release amd64 (20130820.2)
PackageArchitecture: all
ProcEnviron:
 SHELL=/bin/bash
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 XDG_RUNTIME_DIR=<set>
SourcePackage: nginx
UpgradeStatus: Upgraded to trusty on 2014-04-25 (4 days ago)