Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's a throwaway line in there:

> Note, we did get a little more complicated and create a SystemD script to launch it at startup.

There's a good chance that most of what you want is in Systemd.

Restart a process if it fails health checks? Systemd. Do you want to isolate a process in a container? Systemd. Open privileged sockets? Systemd. You can do a lot with Systemd.



Lemme know when the catfight between systemd and docker is over.

I'm a bit busy with chroot and freebsd-jails over here.


I just solaris zone out when people start talking about it.


I was going to mention that but 'zone' skipped my mind. I kept thinking 'solaris sandbox?'


Linux-Vserver all the way.


We had great success using podman for a lot of systemd services


You don't have to worry about that if you don't use Docker as suggested in the OP.


systemd is great. I used it successfully for operations on many projects that I ran. It provides the standardized way to reliably run and manage services on a single machine. I also agree with opponents that shell was the de facto standard way to orchestrate things, allowing you to go from dev to prod without significant changes. I was a fan of runit as a process manager before systemd took over the space.

That said there is a problem when you want to run things on multiple machines. What then? Unix and systemd were not designed as an OS for machine clusters, even though it won't be hard to imagine the concepts to be stretched even to this realm.

The docker/kubernetes crowd has been targeting the multi-machine OS scene much sooner and better, even though the solution of let's pack all dependencies, the entire machine and then some to a fat package and then have it run by a scheduler complex as f seems not like the ultimate future of the space.

I took a look at Nomad as a replacement for Kubernetes, which is much much simpler and you can get up and running with a single binary within 2 hours using this tutorial [0]. Nomad supports not only docker as a backend, but you can run raw_exec backend as well - that is any binary, such as shell script, that you wish to run without packaging the entire world with it. Now imagine if only you could schedule to run systemd units using Nomad. You'd scale from a single machine OS to cluster OS just like that.

I predict that Kubernetes will NOT be the ultimate answer as many are hoping for, betting their careers on it. It is too complex and not supporting other than docker runtimes makes it much inferior product than Nomad. Simple solutions usually win ultimately, so Nomad or systemd extended for multi machine services or even just vanilla linux process management extended to cluster level seem like much saner approaches.

[0] https://medium.com/hashicorp-engineering/hashicorp-nomad-fro...


> Now imagine if only you could schedule to run systemd units using Nomad

With some tweaks to your unit files this is actually possible. Nomad has the concept of custom task drivers you can implement to make it schedule any kind of workload you like. I am maintaining a task driver which allows you to run systemd-nspawn containers with Nomad [1].

Using this task driver you can deploy your systemd units running inside a systemd-nspawn container into a Nomad cluster. If this sounds interesting to you I have written a how-to blog-post about this [2]

[1]: https://github.com/JanMa/nomad-driver-nspawn

[2]: https://janma.tk/2021-01-10/nomad-deploy-systemd-units/


When you say that Kubernetes only supports the Docker runtime I guess you meant only containers as it supports anything that implements CRI (Container Runtime Interface) like containerd.

Think I just saw from your article that Nomad supports straight up Java binaries but don't know how flexible that is


What you describe is essentially the original CoreOS fleet[0] project. It's distributed systemd init files.

[0] https://github.com/coreos/fleet#fleet---a-distributed-init-s...

I find it ironic half of k8s mojo, etcd, came out of this project as well.


What would be the point of using Nomad to orchestrate systemd units instead of just using Nomad to raw_exec stuff? Nomad does health checks and all that, so systemd isn't really needed.

Btw i wrote an article about how great, easy and feature rich Nomad is which might interest you - https://atodorov.me/2021/02/27/why-you-should-take-a-look-at...


I've gotten incredibly far with packer-generated amis, a few build scripts and systemd to keep everything humming along. The only part I'm not a fan of is re-building amis due to the amount of time it takes to bake them.


I have a bunch of platforms that’re just jarfile monoliths (with external db/redis) that we deploy by provisioning the latest Amazon Linux onto EC2, then running a Ansible to configure and add our local dependencies and the jarfile, then run the start script. While our Ansible step runs quickly enough, this is a nice way to not worry too much about managing our own AMIs.

(Two things really help here, we have Windows/macOS/Linux devs all developing and running the code locally so they’re pretty good at not accidentally becoming dependant on stuff outside the JVM, and the healthcheck endpoint the load balancers use is very comprehensive and over the years has been updated to include every non-detected failure or performance degradation.)


Depends on how you bake them. NixOS plus an S3 bucket as a private nix cache should be pretty quick.


The only argument I have heard for Docker that makes any sense to me lately is that when your developers are using macOS and your servers run Linux, it’s nice to have dev/prod parity. Practically I think this speaks to either using better development environments, or writing code that is much more portable than what people try to get away with.


Eh I use docker as essentially disk images

Get something running in any environment really quickly because it is already a separate environment

Nobody has to deal with package managers messing up their system, or have to deal with package manager managers that lets them switch between different versions of a package manager just so they can run some obscure dependency before getting to the project


You just deal with all the library and dependency stuff inside the Docker container instead :)


I was reading some systemd docs the other day, was stunned at how much it can do now


I'm not sure why systemD is needed for restarting a process what about a simple loop with an if statement? Process isolation to run a go binary on a presumably dedicated web server? Privileged sockets, not even sure what those might be.

The point of this post is to not complicate things, but what I hear is even more complicated be it via a docker alternative.


> I'm not sure why systemD is needed for restarting a process what about a simple loop with an if statement?

It's not needed, but that's why a lot of older apps have their very custom solution to deal with that issue. (For example MySQL) Each with their custom exit condition handling, cleanup, backoff, etc. A simple loop also won't cleanup processes forked from the main server.

This 1kLoC script https://github.com/mysql/mysql-server/blob/8.0/scripts/mysql... can be almost entirely replaced with a few lines of systemd.service config. (with fairly logical names for each setting)

Now we can replace those with "Restart=always". If you want to be fancy, you could even add a watchdog.

> Process isolation to run a go binary on a presumably dedicated web server?

1. "presumably" 2. Apparently a web server which gets SSH sessions from devs - nice place to check for forwarded keys or collect passwords.

> Privileged sockets, not even sure what those might be.

Ports below 1024 (or whatever your local threshold is)

> but what I hear is even more complicated

It really isn't. Just unfamiliar to you.


if you go down the Restart=always route, please take a long look at StartLimitIntervalSec, RestartSec, StartLimitBurst. in some failure modes always isn't quite always always.


That's the whole point, you're not mysql. You don't need the sophistication of that magnitude. You need to run a standalone go binary to listen on a port. Simple. Why bother with the blackbox of systemD when you can perfectly get away with a basic shell script?


Yeah it really is complicated, probably just very familiar to you.

I Google systemD the first result has 160 sections just in the documentation table of contents alone [0].

[0] https://www.freedesktop.org/wiki/Software/systemd/


The linked page is not a documentation ToC. Why would you claim that?

For day to day usage there are two man pages which should be enough for reference: https://www.freedesktop.org/software/systemd/man/systemd.exe... and https://www.freedesktop.org/software/systemd/man/systemd.ser...

Or you could start with one of the blog posts linked in the page you referenced.


The first link you sent is 1024 lines long, do you genuinely believe using something like this is preferred to a simple shell script + nohup? I'm amazed at the hoops some devs jump through just to get to work with their favorite tool.


That script is never going to be simple in a few years. You're going to keep adding features to it with time until it badly implementsa tiny fraction of what you already had available in your init system. The question could be: why spend time rewriting a broken restart script if you already have a good version available behind a config switch.

If you don't like how long that man page is, you should check the size of bash+nohub man page which you'd otherwise need :-)


bash + nohup are elementary parts of using Linux, systemD is not and therefore learning it is added complexity.


By his peculiar capitalization you can tell he's a hater that still hasn't come to terms with it, 10 years later.


Or is tired of systemd being auto corrected to systems.


Using camel case means I'm a hater?


> I'm not sure why systemD is needed for restarting a process

You need a systemd unit file that starts your daemon properly when the server boots anyways (most common distros use systemd for init), and it's only a few more lines to make sure it gets restarted if it dies.


Systemd config files are fairly simple and straightforward. It gives a simple interface to start/stop/restart processes and lets you do things like automatically start a process on server boot.


systemd unit files are cleaner than some init scripts, but they only have one implementation, which works on one libc and one kernel. uf.


> only have one implementation, which works on one libc and one kernel

I agree overall, but apparently systemd supports musl. No clue why or who uses it, but it's a thing.


Not according to several people who maintain patches outside of systemd explicitly for musl compatibility.

Did this change recently? Last I heard, systemd maintainers explicitly rejected attempts to support alternate libc implementations.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: