
GNU Shepherd - cyphar
https://www.gnu.org/software/shepherd/
======
gens
There are many amazing GNU projects. Just yesterday I found out about GNU
radio. I also remember reading the initial commit for Gneural and thinking
"wow, this code is really nice".

I think GNU deserves much more support then it's getting.

~~~
thearn4
How does something become an official project under the umbrella of GNU, other
than adopting a GPL? I'm guessing the FSF somehow curates and leads the
individual efforts, before it can be called "GNU $THING"?

~~~
quadrangle
[https://www.gnu.org/help/evaluation.html](https://www.gnu.org/help/evaluation.html)
← how to add your project to GNU

------
georgyo
A service file looks like this:

    
    
      (register-services
        (make <service>
              #:provides '(apache-2.0 apache httpd)
              #:requires '()
              #:start (...)
              #:stop (...)
              #:actions (make-actions
                         (reload-modules (...))
                         (restart (...)))))
    
    

It not horrible, but I'm Not a huge fan of that, but maybe it will get much
better as it matures.

~~~
agumonkey
reminds me of emacs config file, john wiegley made a tiny dsl called use-
package that made everything cuter by a few simplification here and there. A
few iteration it became extremely nice to write and read.

~~~
rbanffy
Remember the Emacs config file is not a configuration file: it is actually a
program that's run as Emacs starts. You can do all sorts of interesting stuff
(like installing missing packages, setting font size according to the screen,
etc) on it.

~~~
agumonkey
Well config vs program is a deep debate. Now J.Wiegley extension brings some
resemblance of semantics because it has a few concepts and steps instead of
free form imperative (setq ...)

------
jonaf
I can appreciate how holistic the GNU ecosystem seems to be. I'm a lover and
user of Nix, so whenever something about Guix comes up, I draw the contrast.
In this case, GuixSD is using Shepherd, which uses Guile for configuration and
feels like natural continuity within the system. NixOS, on the other hand,
provides systemd (and only systemd). In the case of nix, it's smart to
leverage existing technologies, for velocity, yes, but also as a sort of proof
that the core principles behind nix can apply even over systems and tools that
are completely unaware of nix concepts; on the other hand, GNU really makes me
a believer in the fact that Guix is very pure.

------
satai
How do they keep eye on all the processes for a service. They don't seem to
use namespaces.

~~~
cyphar
I'm trying to read the code now. I'm not sure whether I do or don't want them
to use cgroups. Anything is better than using ptrace.

~~~
m-j-fox
Aren't cgroups a Linux thing? Don't know if Hurd has them.

~~~
bonzini
Cgroups are just an API. I think there was an effort to add a translator for
them on top of the Hurd, possibly as a Summer of Code project.

------
josteink
For those too lazy to click the link

> The GNU Daemon Shepherd or GNU Shepherd, formerly known as GNU dmd

dmd was short for "daemon management daemon". Basically, it's what powers all
services running on GNU Guix instead of something else, like systemd.

I think this new name may sound "friendlier", but at the cost of precision. I
immediately realized what dmd would be, but I had no idea what GNU Shepherd
would be about.

~~~
cygx
Daemon managing daemons, actually. Also note that Guix is technically just the
package manager - the distro is called GuixSD.

------
bostand
It will be interesting to see if we can use this in linux with minimal changes
to the test if the system

(I am looking at you systemd)

~~~
klez
It's already used in Guix, that is a GNU/Linux distribution, so why not?

~~~
rekado
Actually, it's used in GuixSD, the GNU system variant built on top of Guix.

~~~
tgjsrkghruksd
Oh come on. And what's the kernel for GuixSD? Linux.

We all know RMS is bitter that he can't take credit for a functional kernel,
but it's still there.

~~~
josteink
> Oh come on. And what's the kernel for GuixSD? Linux.

They called you out on a minor mistake: Guix being a package-manger of sorts
and GuixSD being a Linux distro (built on Guix).

And Guix doesn't run anything like dmd or systemd. GuixSD does.

It's not a big deal though. Honest mistake to make.

~~~
klez
I'm the one who said Guix instead of GuixSD, I'm a different person than the
one who made the comment about Linux and RMS.

------
MrF3ynmann
So is this GNU/systemd?

~~~
gkya
This is init, with the exceptional property that you write your scripts in
Guile Scheme (an implementation of a standardised Lisp dialect). That should
allow for a more robust and debuggable way to write init scripts.

GuixSD is kind of immature at the moment, and I have driver issues with linux-
libre, but in the coming weeks I'll have the time to try to run it with a
custom kernel that supports my hardware. If I succeed, as an Emacs user it'll
become turtles all the way for me, which is very exciting (GuixSD is Guix +
Shepherd + GNU + Linux Libre).

~~~
rekado
"kind of immature" is a bit vague, but I disagree. I'm using GuixSD on almost
all of my machines (a server, two laptops, an audio workstation) without
problems.

It is quite easy to overwrite the kernel package to use in a system
configuration (e.g. to use a kernel with the RT patches applied), but I should
say that I use the default kernel on all but one machine.

------
giancarlostoro
Kinda odd they ever called it dmd at all considering that's the name of the
official D compiler.

~~~
rekado
Not so odd considering that Shepherd was started in the year 2002 and the D
language appeared at the end of 2001.

~~~
giancarlostoro
That makes more sense to me, I was not aware of the history of Shepherd.
Funnily enough they changed the name to avoid this very confusion in 2016.

~~~
rekado
That's because the D language people asked for a name change then. The
Shepherd was actually a dormant project for many years until it was revived
for GuixSD.

------
amq
Would it be a suitable replacement for supervisord in containers?

~~~
cyphar
Most likely. It can even run as an unprivileged user (and users can manage
their own daemons with it).

Though in most cases I find that people just want the "zombie problem" to go
away. I wrote a simple init[1] that implements all of the key pieces of an
init and signal forwarder.

[1]: [https://github.com/cyphar/initrs](https://github.com/cyphar/initrs)

~~~
majewsky
I see you mentioned tini (another such init) in the README as being "not as
simple as it should be". We're using [https://github.com/Yelp/dumb-
init](https://github.com/Yelp/dumb-init) at work; if you know it, what do you
think of it?

~~~
cyphar
dumb-init is better, but they don't use socketfd which means they might drop
signals in certain cases (in the race between consecutive sigwaits). I will
concede this is a minor point, and I still have to finish implementing all of
the necessary signal semantics in initrs, but it is kinda important.

Also I'm learning Rust and it was a good opportunity to practice by
implementing something I already knew how to easily do in C.

------
Zardoz84
how compares against SystemD kraken ?

