From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Vollmert Subject: Re: where to put helper to send stdout/stderr to syslog? Date: Tue, 18 Jun 2019 18:44:03 +0200 Message-ID: References: <20190617144549.3430003f@scratchpost.org> <87v9x3588r.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:58114) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdHDQ-0006Oe-Ti for guix-devel@gnu.org; Tue, 18 Jun 2019 12:44:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdHDP-000627-Tc for guix-devel@gnu.org; Tue, 18 Jun 2019 12:44:12 -0400 In-Reply-To: <87v9x3588r.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: =?utf-8?Q?Ludovic_Court=C3=A8s?= Cc: guix-devel@gnu.org > On 18. Jun 2019, at 15:32, Ludovic Court=C3=A8s wrote: >=20 > Hi, >=20 > Danny Milosavljevic skribis: >=20 >> 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 = :) >=20 > +1! >=20 >> 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 >=20 > Yes, that should be enough. >=20 > Robert, would you like to give it a go? I=E2=80=99d rather not get too deep into shepherd at this point. Here=E2=80=99s the wrapper updated in response to Danny=E2=80=99s = 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=3D" 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