Opened 7 months ago

Closed 7 months ago

#1715 closed defect (wontfix)

Logs are no longer written to /dev/stdout after HUP, if daemon is on

Reported by: CamJN@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.15.x
Keywords: Cc:
uname -a: Darwin SECUR-T.local 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
nginx -V: nginx version: nginx/1.15.8 built by clang 10.0.0 (clang-1000.11.45.5) built with OpenSSL 1.0.2q 20 Nov 2018 TLS SNI support enabled configure arguments: --prefix=/usr/local/Cellar/nginx-passenger-enterprise/1.15.8 --sbin-path=/usr/local/Cellar/nginx-passenger-enterprise/1.15.8/bin/nginx --with-cc-opt='-I/usr/local/opt/pcre/include -I/usr/local/opt/openssl/include' --with-ld-opt='-L/usr/local/opt/pcre/lib -L/usr/local/opt/openssl/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-debug --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-ipv6 --with-mail --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/usr/local/Cellar/passenger-enterprise/6.0.1/libexec/src/nginx_module

Description

In Passenger standalone we generate a config and start Nginx for the user. It has daemon on; set. When the apps that the user is running change, we generate a new config, then send HUP to Nginx to get it to reread the config. If logs are being written to a file, this works fine. However if the logs are being written to /dev/stdout (for example in a docker setup) then after the HUP Nginx stops writing logs to /dev/stdout.

If daemon off; is set in the config then the logs continue to be written to /dev/stdout after the HUP.

I'd expect Nginx to continue to write logs to /dev/stdout after a HUP, and hope this can be fixed.

Change History (1)

comment:1 Changed 7 months ago by mdounin

  • Resolution set to wontfix
  • Status changed from new to closed

This is because opening /dev/stdout duplicates existing file descriptor 1 (STDOUT_FILENO). Standard output is redirected to /dev/null as a part of daemonization, so further attempts to open /dev/stdout after daemonization (on HUP signal in your case) will result in opening /dev/null.

If you want to write logs to stdout, consider switching off daemonization. Alternatively, consider writing logs to stderr. The stderr descriptor is preserved during daemonization, and normally nginx redirects it to the log file. With logging to stderr it will continue to point to stderr.

(Also, a special value 'stderr' can be used to explicitly request logging to stderr, so nginx will know it is logging to stderr. In contrast to /dev/stderr, this also works on Windows, and should also produce slightly more friendly results than /dev/stderr, as nginx will know there is no need to write startup errors to stderr, and/or to redirect stderr to the log after startup.)

Note: See TracTickets for help on using tickets.