From: Robert Vollmert <rob@vllmrt.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: where to put helper to send stdout/stderr to syslog?
Date: Tue, 18 Jun 2019 18:44:03 +0200 [thread overview]
Message-ID: <C097480D-5CAD-4431-95CD-397CEBB69C2B@vllmrt.net> (raw)
In-Reply-To: <87v9x3588r.fsf@gnu.org>
> On 18. Jun 2019, at 15:32, Ludovic Courtès <ludo@gnu.org> wrote:
>
> Hi,
>
> Danny Milosavljevic <dannym@scratchpost.org> skribis:
>
>> I think it could be made part of shepherd and be exported there, then everyone
>> could use it. Logging to syslog isn't exactly an obscure requirement :)
>
> +1!
>
>> Although shepherd already has its own /dev/log (syslog) client implementation,
>> the external "logger" executable (or similar) is still necessary, because
>> /dev/log is a UNIX domain socket and one can't write to UNIX domain sockets
>> the same way one does pipes. Although it might be possible (and not
>> advisable) to connect() the socket and then dup it to 1 and 2 for the child :P
>
> Yes, that should be enough.
>
> Robert, would you like to give it a go?
I’d rather not get too deep into shepherd at this point.
Here’s the wrapper updated in response to Danny’s comments, in case you want to
reuse that inside shepherd:
(define* (logger-wrapper name exec . args)
"Return a derivation that builds a script to start a process with
standard output and error redirected to syslog via logger."
(define exp
#~(begin
(use-modules (ice-9 popen))
(let* ((pid (number->string (getpid)))
(logger #$(file-append inetutils "/bin/logger"))
(args (list "-t" #$name (string-append "--id=" pid)))
(pipe (apply open-pipe* OPEN_WRITE logger args)))
(dup pipe 1)
(dup pipe 2)
(execl #$exec #$exec #$@args))))
(program-file (string-append name "-logger") exp))
Cheers
Robert
prev parent reply other threads:[~2019-06-18 16:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-16 12:22 where to put helper to send stdout/stderr to syslog? Robert Vollmert
2019-06-17 12:45 ` Danny Milosavljevic
2019-06-17 13:12 ` Robert Vollmert
2019-06-17 14:45 ` Danny Milosavljevic
2019-06-18 13:32 ` Ludovic Courtès
2019-06-18 16:44 ` Robert Vollmert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C097480D-5CAD-4431-95CD-397CEBB69C2B@vllmrt.net \
--to=rob@vllmrt.net \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).