[systemd-devel] [systemd-nspawn] nginx: [emerg] open() "/dev/stderr" failed (6: No such device or address)

Peter Paule systemd-devel at fedux.org
Sun Apr 26 05:32:19 PDT 2015


Excerpts from Lennart Poettering's message of 2015-04-24 16:40:07 +0200:
> > Hmm, I'm pretty sure the default StandardOutput=journal means stdout
> > will be a socket connection to journald, doesn't it?
> 
> Ah, true!
> 
> > (And since it's a process-specific thing, "echo "asdf" > /dev/stdout"
> > from an interactive shell will merely test the shell's stdout (which
> > is a tty), not nginx's stdout...)
> 
> Indeed.
> 
> I figure /dev/stderr is simply not compatible with sockets, regardless
> if nspawn is in the mix or not... WHich actually came up before, and I
> think is someething to accept...

Yes, I can confirm this. 

Using no service unit + running it with nspawn is successful:

  root at localhost ~ # /usr/bin/systemd-nspawn --register=no --ephemeral -M centos-nginx-systemd-latest dd if=/dev/zero of=/dev/stderr bs=1M
  count=5Spawning container centos-nginx-systemd-latest on
  /var/lib/machines/.#centos-nginx-systemd-latest0d04351874786361.
  Press ^] three times within 1s to kill container.
  5+0 records in
  5+0 records out
  5242880 bytes (5.2 MB) copied, 0.236759 s, 22.1 MB/s
  Container centos-nginx-systemd-latest exited successfully.

But it fails when it is started via service-unit:
  
  root at localhost ~ # systemctl start nginx at example_com
  root at localhost ~ # systemctl status nginx at example_comnginx at example_com.service - Webservice for example_com
     Loaded: loaded (/etc/systemd/system/nginx at .service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Sun 2015-04-26 14:24:54 CEST; 2s ago
    Process: 5209 ExecStart=/usr/bin/dd if=/dev/zero of=/dev/stderr bs=1M count=5 (code=exited, status=1/FAILURE)
   Main PID: 5209 (code=exited, status=1/FAILURE)
  
  Apr 26 14:24:54 localhost systemd[1]: Started Webservice for example_com.
  Apr 26 14:24:54 localhost systemd[1]: Starting Webservice for example_com...
  Apr 26 14:24:54 localhost systemd[1]: nginx at example_com.service: main process exited, code=exited, status=1/FAILURE
  Apr 26 14:24:54 localhost systemd[1]: Unit nginx at example_com.service entered failed state.
  Apr 26 14:24:54 localhost systemd[1]: nginx at example_com.service failed.
  Apr 26 14:24:54 localhost dd[5209]: /usr/bin/dd: failed to open ‘/dev/stderr’: No such device or address
  3 root at localhost ~ #                                                                                            

> People should really use the shell construct "2>" instead of ">
> /dev/stderr" if they want the redirect to work always.

BTW: I did the `echo "asdf" > /dev/stderr`-thing just to test if
`/dev/stderr` worked as expected.

What I do not understand is: What changed in systemd that the
service-unit-thing worked in some earlier versions? And what can I do to make
it work again? There seems to be no other logging target _today_ both for nginx
and apache which makes them compatible with journald.

/pp


More information about the systemd-devel mailing list