Re: [systemd-devel] How to log to journald using fifo?

2016-04-14 Thread Lennart Poettering
On Wed, 13.04.16 23:43, Samuel Williams (space.ship.travel...@gmail.com) wrote:

> I guess what I'm proposing is not a specific workaround but a way for
> legacy software which can only log to a file to get it's data into
> journald. There is plenty of software like that, unfortunately. It's a
> pragmatic option.
> 
> In this specific case, I'm referring to Nginx in daemon mode, which closes
> /dev/stderr as far as I can tell, and then spawns passenger, which can only
> log to a file. There is no way to hook up passenger to /dev/stderr.

Hmm, this might work: "touch /tmp/ && mount --bind /proc/self/fd/2 
/tmp/"

That will bind mount your fd 2 to /tmp/, and then you can reopen it from 
there later...

(Didn't try that this actually works, but I think this should pin the
open fd. YMMV.)

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to log to journald using fifo?

2016-04-13 Thread Mantas Mikulėnas
On Wed, Apr 13, 2016 at 2:43 PM, Samuel Williams <
space.ship.travel...@gmail.com> wrote:

> I guess what I'm proposing is not a specific workaround but a way for
> legacy software which can only log to a file to get it's data into
> journald. There is plenty of software like that, unfortunately. It's a
> pragmatic option.
>
> In this specific case, I'm referring to Nginx in daemon mode, which closes
> /dev/stderr as far as I can tell, and then spawns passenger, which can only
> log to a file. There is no way to hook up passenger to /dev/stderr.
>
> The proposed service allows anyone to set up a fifo for logging in this
> situation, it's very trivial and easy to set up, but I suspect there is
> more than just one person with this issue.
>

If you're going to run a service anyway, could you use e.g. rsyslog's
imfile → omjournal modules?

-- 
Mantas Mikulėnas 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to log to journald using fifo?

2016-04-13 Thread Samuel Williams
I guess what I'm proposing is not a specific workaround but a way for
legacy software which can only log to a file to get it's data into
journald. There is plenty of software like that, unfortunately. It's a
pragmatic option.

In this specific case, I'm referring to Nginx in daemon mode, which closes
/dev/stderr as far as I can tell, and then spawns passenger, which can only
log to a file. There is no way to hook up passenger to /dev/stderr.

The proposed service allows anyone to set up a fifo for logging in this
situation, it's very trivial and easy to set up, but I suspect there is
more than just one person with this issue.

On 12 April 2016 at 02:21, Lennart Poettering  wrote:

> On Sun, 10.04.16 22:57, Samuel Williams (space.ship.travel...@gmail.com)
> wrote:
>
> > Hello,
> >
> >
> > I've been trying to figure out the best way to support legacy
> applications
> > that don't support syslog for logging. The best we can do, I think, is to
> > use fifo and have another process read the fifo to journald.
>
> Note that on systemd everything logged out stdout or stderr ends up in
> the journal anyway. And you can specify /dev/stderr or /proc/self/fd/2
> as path referring to stderr on Linux generally, if you need.
>
> > Finally, if this is a good approach, is this method worth putting into
> > systemd/journald as a standard service? If so, how do I submit a PR or
> > where to begin?
>
> Specific work-arounds around other, unrelated pieces of software are
> not really what we we'd like to add to systemd directly. Sorry.
>
> Lennart
>
> --
> Lennart Poettering, Red Hat
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to log to journald using fifo?

2016-04-11 Thread Lennart Poettering
On Sun, 10.04.16 22:57, Samuel Williams (space.ship.travel...@gmail.com) wrote:

> Hello,
> 
> 
> I've been trying to figure out the best way to support legacy applications
> that don't support syslog for logging. The best we can do, I think, is to
> use fifo and have another process read the fifo to journald.

Note that on systemd everything logged out stdout or stderr ends up in
the journal anyway. And you can specify /dev/stderr or /proc/self/fd/2
as path referring to stderr on Linux generally, if you need.

> Finally, if this is a good approach, is this method worth putting into
> systemd/journald as a standard service? If so, how do I submit a PR or
> where to begin?

Specific work-arounds around other, unrelated pieces of software are
not really what we we'd like to add to systemd directly. Sorry.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to log to journald using fifo?

2016-04-10 Thread Samuel Williams
I would like to write to /dev/stderr and tried that but it didn’t work. I think 
it’s something to do with the way it works internally (nginx + phusion 
passenger).

> On 11/04/2016, at 12:43 AM, Mantas Mikulėnas  wrote:
> 
> On Sun, Apr 10, 2016 at 1:57 PM, Samuel Williams 
> mailto:space.ship.travel...@gmail.com>> 
> wrote:
> Hello,
> 
> I've been trying to figure out the best way to support legacy applications 
> that don't support syslog for logging. The best we can do, I think, is to use 
> fifo and have another process read the fifo to journald.
> 
> I made the following unit journald-fifo@.service
> 
> [Unit]
> Description=A fifo for logging to journald
> AssertPathExists=/var/log/%i.fifo
> 
> [Service]
> Type=simple
> ExecStart=/bin/sh -c 'while true; do systemd-cat -t %i < /var/log/%i.fifo; 
> done'
> Nice=5
> 
> [Install]
> WantedBy=multi-user.target
> 
> I was wondering is this a good approach? Is there a better way? (of course, 
> we'd like to fix the original software to work better).
> 
> If the software can log to stdout/stderr, just use that. If not, make it 
> write logs to "/dev/stderr". Either way, systemd will log service stdout 
> automatically.
> 
> -- 
> Mantas Mikulėnas mailto:graw...@gmail.com>>

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to log to journald using fifo?

2016-04-10 Thread Mantas Mikulėnas
On Sun, Apr 10, 2016 at 1:57 PM, Samuel Williams <
space.ship.travel...@gmail.com> wrote:

> Hello,
>
>
> I've been trying to figure out the best way to support legacy applications
> that don't support syslog for logging. The best we can do, I think, is to
> use fifo and have another process read the fifo to journald.
>
>
> I made the following unit journald-fifo@.service
>
>
> [Unit]
>
> Description=A fifo for logging to journald
>
> AssertPathExists=/var/log/%i.fifo
>
>
> [Service]
>
> Type=simple
>
> ExecStart=/bin/sh -c 'while true; do systemd-cat -t %i < /var/log/%i.fifo;
> done'
>
> Nice=5
>
>
> [Install]
>
> WantedBy=multi-user.target
>
> I was wondering is this a good approach? Is there a better way? (of
> course, we'd like to fix the original software to work better).
>

If the software can log to stdout/stderr, just use that. If not, make it
write logs to "/dev/stderr". Either way, systemd will log service stdout
automatically.

-- 
Mantas Mikulėnas 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] How to log to journald using fifo?

2016-04-10 Thread Samuel Williams
Hello,


I've been trying to figure out the best way to support legacy applications
that don't support syslog for logging. The best we can do, I think, is to
use fifo and have another process read the fifo to journald.


I made the following unit journald-fifo@.service


[Unit]

Description=A fifo for logging to journald

AssertPathExists=/var/log/%i.fifo


[Service]

Type=simple

ExecStart=/bin/sh -c 'while true; do systemd-cat -t %i < /var/log/%i.fifo;
done'

Nice=5


[Install]

WantedBy=multi-user.target

I was wondering is this a good approach? Is there a better way? (of course,
we'd like to fix the original software to work better).


Finally, if this is a good approach, is this method worth putting into
systemd/journald as a standard service? If so, how do I submit a PR or
where to begin?


Kind regards,

Samuel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel