delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/02/26/13:43:32

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:from:date:message-id:subject:to
:content-type; q=dns; s=default; b=vILMm+cLoX08yElXbaHkJHw/RxVj9
Ek7r+HT74u4sWZpJ2uEzF0vj0/4Z8k5+IHGocKMJBzRN7cX5DhPeOsnPCp3VqoTe
jWebRIn129oJgbzIHTasOsLritHlvYEYQqQOkVPijYJV6QJLW+GRRkQL3tarsVOc
ZntSWV7RmlNXHo=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:from:date:message-id:subject:to
:content-type; s=default; bh=cQm2RlnYkImvsWjtXHclTcjHVK4=; b=Hqs
tn8ZKaFOMjyjpF+TX6Ly+j3Xg0K20eYt6DRQWIAyTZyDHYz4wCwTvxdvzPM6em3b
k1HRjsJekKPAmfX+R+FdtzT3hrXuGRg0S4fWkO98o8LaaS8t/et52RT5oI8cVuZI
xVw5rhAwbArfobPcvHMZdrfDRU8rP3BU+8iPth0s=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=PID, ppid, policy, site
X-HELO: mail-wr0-f172.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=I/z3e8JGHkgM56KxfviflMPOzF0P3lSwxUOpSlLBb6c=; b=IQ9e0Qu60bM5vWydpVXcBMKB/DA89M4N4MMDccsT3rGu6J+MUl1BlvQ4AnCvLoz5NV GYFEogxpJo+ksMPUFnn9vmkagZ7CETL9g/ueMKw+iT6mh7OrE5oUZ1Twsacdd90/nwAU tTSc5vpj4sRYOHC+LAvPaPGM9cir5wwOt7Nqi287NszGQxit1BFC9l7KCj6onIjLGW0l pr/LmofbIvaJavj2rTEaKGDiC4VAOltQ4AEJA8Q2raBSWA1IBBhLnFs8a6GuuYSgbaqP r5zcGOQ7eW8VXQ78+W3P9oENrGXxmk9Tm1cNH0+067pMjynrTV9G1wvFyRku64t1M6+2 HOSw==
X-Gm-Message-State: AMke39nXr1bc6w0B+JhgIQuslbxRcDL29cyYf30FBfB3WU29e46g9sUPvc35b1F8eMUuGbmG325AT93CtZ+AVw==
X-Received: by 10.223.169.140 with SMTP id b12mr11364225wrd.138.1488134593522; Sun, 26 Feb 2017 10:43:13 -0800 (PST)
MIME-Version: 1.0
From: Anders Sandvig <anders DOT sandvig AT gmail DOT com>
Date: Sun, 26 Feb 2017 19:42:33 +0100
Message-ID: <CALU3vWRY3GbXmB_+RABd_LnE-PiXmzf3_F0+1HfuAeEGh0O90A@mail.gmail.com>
Subject: nginx-1.10.3-1 refusing to start after installation (missing directories)
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

I installed the nginx-1.10.3-1 Cygwin (x86) package today, and while the install
process itself was successful, the program did not work as expected after
installation.

Starting nginx after installing it via Cygwin Setup:

    $ /usr/sbin/nginx.exe
    nginx: [alert] could not open error log file: open()
"/var/log/nginx/error.log" failed (2: No such file or directory)
    2017/02/26 16:45:17 [emerg] 11500#0: mkdir()
"/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)
    $ ps aux
          PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
         8336       1    8336       8336  ?         197609 15:38:50
/usr/bin/mintty
        11596    1412   11596      10568  pty3      197609 17:25:54 /usr/bin/ps
         1412    8336    1412      10028  pty3      197609 15:38:50
/usr/bin/bash

Trying to check nginx configuration file for errors:

    $ /usr/sbin/nginx.exe -T
    nginx: [alert] could not open error log file: open()
"/var/log/nginx/error.log" failed (2: No such file or directory)
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    2017/02/26 16:47:08 [emerg] 8092#0: mkdir()
"/var/lib/nginx/tmp/client_body" failed (2: No such file or directory)
    nginx: configuration file /etc/nginx/nginx.conf test failed

Work-around:

    $ mkdir -p /var/log/nginx
    $ mkdir -p /var/lib/nginx/tmp

After creating the two missing directories, starting nginx works as expected
and the server gives the default nginx site on localhost:

    $ /usr/sbin/nginx.exe -T
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    ...
    $ /usr/sbin/nginx.exe
    $ ps aux | grep nginx
         1964       1    1964       1964  ?         197609 17:27:31
/usr/sbin/nginx
        12424    1964    1964      12424  ?         197609 17:27:31
/usr/sbin/nginx
    $ nc localhost 80
    GET / HTTP/1.1
    Host: localhost

    HTTP/1.1 200 OK
    Server: nginx/1.10.3
    ...

I suspect this problem could be fixed by modifying the package install scripts
to create the missing directories during the install process? I had a quick
look at the postinstall and preremove scripts for the nginx pacakge, and they
do not seem to do anything with regards to /var/log/nginx or /var/lib/nginx.

Proposed addition to /etc/postinstall/nginx.sh:

    if [ ! -d /var/log/nginx ]
    then
        /usr/bin/mkdir -p /var/log/nginx
    fi
    if [ ! -d /var/lib/nginx/tmp ]
    then
        /usr/bin/mkdir -p /var/lib/nginx/tmp
    fi

Proposed addition to /etc/preremove/nginx.sh:

    # Only remove log directroy if it's empty.
    if [ -z "$(ls -A /var/log/nginx)" ]
    then
        /usr/bin/rm -r /var/log/nginx
    fi

    # Always remove tmp directory (assuming that's safe?)
    if [ -d /var/lib/nginx/tmp ]
    then
        /usr/bin/rm -r /var/lib/nginx/tmp
    fi
    # Only remove tmp parent directory if tmp was the only thing in it.
    if [ -z "$(ls -A /var/lib/nginx)" ]
    then
        /usr/bin/rm -r /var/lib/nginx
    fi

I'm not familiar with the details of the Cygwin package install process (and
not very good at Bash scripting either), so I don't know if this is the right
way (or the right places) to fix the issue, but hopefully the intention of the
proposed solution is clear.

I'm also not sure what Cygwin's policy is on removing (user) files when
uninstalling a package, but I think leaving the log files, if any, is the
"right" thing to do?

One might argue that /var/log should also be removed if it did not exist when
nginx was first installed, but that may be outside the scope of the install
script of any single package? I already had /var/log on my system for
unrelated reasons, but others may not. (I don't know if there are other
Cygwin packages that create /var/log during their install or depend on it
being present.)


Regards,

Anders Sandvig

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019