From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emn54-0002gP-Bd for guix-patches@gnu.org; Fri, 16 Feb 2018 15:58:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emn50-0003kN-8k for guix-patches@gnu.org; Fri, 16 Feb 2018 15:58:06 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:39361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1emn50-0003kI-5d for guix-patches@gnu.org; Fri, 16 Feb 2018 15:58:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1emn4z-0005t9-Ri for guix-patches@gnu.org; Fri, 16 Feb 2018 15:58:01 -0500 Subject: [bug#30464] shepherd logging; console-agetty-service Resent-Message-ID: Date: Fri, 16 Feb 2018 21:57:25 +0100 From: Danny Milosavljevic Message-ID: <20180216215725.58607c8c@scratchpost.org> In-Reply-To: <878tbu8dat.fsf@gnu.org> References: <20180215114256.551-1-dannym@scratchpost.org> <20180215114742.663-1-dannym@scratchpost.org> <87r2pm8gfl.fsf@gnu.org> <20180215164135.188beed0@scratchpost.org> <878tbu8dat.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 30464@debbugs.gnu.org Hi Ludo, On Thu, 15 Feb 2018 16:47:54 +0100 ludo@gnu.org (Ludovic Court=C3=A8s) wrote: > (Which has me thinking that longer term it=E2=80=99d be nice to have the > Shepherd take care of syslogd-ish activity.) If you mean that we should make sure to log shepherd's own messages, I agre= e. Integrating syslogd into shepherd, not sure. I think external syslogd is f= ine. If not, there are a lot of other logging programs to choose from. I like modularity. shepherd could write its messages to the kernel log ringbuffer in /dev/kmsg= [3]. That sounds dirty, but it would synchronize messages oh-so-nicely and would not immediately require syslogd. It would also make sure that syslogd eventually picks shepherd's messages up (right now they are somewhere on the first terminal - if you are lucky and they didn't scroll off). I'm not sure whether then they would be printed to /dev/console as well the= n - probably. We'd need a guile soft-port, but it's not like I haven't done that before. User-shepherd shouldn't do it though (and can't because it doesn't have permission to write to /dev/kmsg). Please stop me and tell me why it's a bad idea :) Also a way of capturing stderr and stdout (and maybe even /dev/log) of serv= ices would be nice. If you thought that the above was bad, you ain't seen nothing yet :-> We could also instead open /dev/klog and dup2 its fd to 1 and 2. That way, shepherd messages and all stray messages by any process shepherd started will end up in the kernel log. (problem: there are some reserved patterns that have special meaning - and we don't control what the services do as well as we do what just shepherd does) Also, I know one is supposed to write UNIX services as daemons, but that's not really composable and kinda complicated to debug for no good reason. I'd prefer if shepherd also keeps a way to run regular programs as services, making sure that they are session leader, their output is logged, they are kept alive and monitored. daemontools[1][2] have done all this stuff already and I like it much more than traditional service managers. It's much more modular, handles logging on its own, handles error cases well, uses the file system well etc, handles errors in the loggers (!). > How about adding a =E2=80=98dependencies=E2=80=99 field to ? It=E2=80=99d > default to the empty list, and could be set to '(syslogd) in this case. >=20 > Does that sound too obscure to you, or would it be OK? Sure, let's do that. It's a little weird to have it for all agettys, although maybe some other u= sers of agetty require it anyway. Then I wonder if all guix shepherd service configs should have such a field. [1] https://isotope11.com/blog/manage-your-services-with-daemontools [2] https://cr.yp.to/daemontools/faq/create.html [3] https://cgit.freedesktop.org/systemd/systemd/tree/src/journal/journald-= kmsg.c dev_kmsg_fd =3D open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); printf "<%i>" priority identifier "[" pid "]: " message "\n" Linux: /* * Extract and skip the syslog prefix <[0-9]*>. Coming from userspace * the decimal value represents 32bit, the lower 3 bit are the log * level, the rest are the log facility. * * If no prefix or no userspace facility is specified, we * enforce LOG_USER [which is 1], to be able to reliably distinguish * kernel-generated messages from userspace-injected ones. */