[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where to put helper to send stdout/stderr to syslog?

From: Robert Vollmert
Subject: Re: where to put helper to send stdout/stderr to syslog?
Date: Tue, 18 Jun 2019 18:44:03 +0200

> On 18. Jun 2019, at 15:32, Ludovic Courtès <address@hidden> wrote:
> Hi,
> Danny Milosavljevic <address@hidden> 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
        (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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]