by INTPenis · 10y ago · 0 comments
I love bash, I love nitpicking about how to use bash along with the other bash nazis in #bash@freenode. But I would never put myself through sysvinit again. I thoroughly enjoy using distros like CentOS 7, Fedora 23, RHEL7. They're a joy to manage and work with, in part thanks to Systemd.
I never want to debug, troubleshoot, or even look at another sysvinit-script again. :)
But that could easily be explained by the average complexity of services increasing along with my career path into Linux and Devops.
I don't remember any clear differences between sysvinit and rc, the scripting is still left up to the user which means code style can diverge from whatever the maintainers had in mind.
Systemd, albeit a binary blob, at least eliminates that from the equation and breaks down services into a limited number of types that it handles equally every time.
I actually liked upstart too. :) I might sound mad for saying that but as a user of Linux upstart gave me just what I wanted.
Bottom line is that I think discussions about scripting style have no place in the context of service management. Services should be dealt with in a simple way like upstart or systemd. If you want to add more complexity you can write a start script for the service but that should not be the norm.
van Smoorenburg rc and Mewburn rc are noticably different.
* https://news.ycombinator.com/item?id=11550802
They are both rc, by the way. Don't conflate init and rc.
> If you want to add more complexity you can write a start script for the service but that should not be the norm.
In some fields, it appears that it is.
* http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/sy...
The biggest problem with java is knowing when the service is started. And that's actually a problem with other clustered services like wsrep in mariadb for example. You need to get an OK from the service, by checking logs or APIs, before you know that the restart worked.
So services like that will always require an added layer of abstraction. But that's not the norm, far from it.
This is commonly provided by the port maintainer - I haven't conducted a survey but I'm pretty confident that service scripts in FreeBSD ports rarely make it into rc.d without a deliberate freebsdization.
I rarely make use of the BSD scripts provided but I like them as simple examples of how various services are intended to be run.
I find there is a certain amount of uniformity and consistency and arguably coherence to the rc.d system.
If you mean to figure out what was actually executed for a unit "systemctl cat [service name]" will tell you the full path of each file systemd processed for that service and what content was pulled from it.
It's possible to run sysvinit sanely, by having a few startup scripts that source in the appropriate boilerplate. Slackware's startup for instance has always been manageable.
The troubleshooting is ridiculous, too, because of the ridiculousness that comes with journald. Why does it feel the need to make me run an awfully formatted, and potentially complex set of parameters to print that? Especially considering that 9/10 times, the error message from journald is vague, ungreppable without -A or -B, and is often significantly shorter than the "use journald to print the error" output. So frustrating. I don't know how people deal with it.
That said, I'm not a fan of sysvinit, either, but I don't have to deal with as much smoke and mirror behavior with it.
OpenRC fixes a lot of that, without adding the giant pile of dependencies that systemd imposes. As someone who is already comfortable with bash, OpenRC scripts should be easy.
> I can't believe anyone would like to keep using sysvinit-scripts or RC-scripts.
There are more options than sticking with Debian's ancient scripts.
The larger problem is that init is only a tiny part of systemd. Systemd's mandatory link-time dependencies and tightly-coupled (monolithic) features are trying to be an entire wrapper around important parts of the kernel. Even if you like the init features of systemd, you should be looking at all the changes; do you really want to depend on all of systemd's features in the future? Do you enjoy depending on a moving target that changes at the whim of the systemd cabal and their reputation for WONTFIXing anything that they don't understand or haven't considered as a use case?
That's because you can't reasonably fix the many problems with sysvinit (or OpenRC) without also providing a proper process manager, and dependency system that does far more than just trigger scripts in the right order.
The biggest problem with init is that it's just init.
> Do you enjoy depending on a moving target that changes at the whim of the systemd cabal and their reputation for WONTFIXing anything that they don't understand or haven't considered as a use case?
I don't enjoy that, but the alternative of relying on sysvinit or OpenRC is so many times worse.
Give me a better alternative, and I'll throw Systemd out of the window immediately. But to be better it will need to at a minimum:
- Be able to sanely handle service restarts, including configurable behaviour on failure.
- Be able to ensure service output is sanely logged.
- Be able to reliably keep track of processes belonging to a service even if they double fork or the prent process dies.
- Have a dependency system that allows starting and stopping services automatically depending on the status of other services, the availability of a directory or file.
- Be able to schedule execution (like cron) but still subject them to the process management and dependency rules.
.. to mention some.
Why does init have to service supervision? What's wrong with having init just launch the service supervision process and afterwards just reap dead processes (which allows init to be a very simple program indeed [1]).
As for the requirements to the init+rc system.. mine look a bit different: it should be reliable and predictable first.. performance not so much.
OpenRC works pretty well for me, the only thing I would change right now is to replace that start-stop-daemon rubbish with runit (and there is work under way to allow that if I am not mistaken).
Now you will probably say that anything still using start-stop-daemon is strictly worse than whatever systemd does, because it won't restart the daemon at all if it crashes (and is ugly in some other ways too). I would agree with that in theory, however in my case this happens rarely enough that it is the smaller evil versus the systemd system sometimes not booting properly at all.
daemontools
A series of scripts that run the supervise program. It initially runs svscanboot [1], which enables logging and uses svscan [2] to look through a service directory in order to execute the supervise executable for each service. [3] Supervise loads the run command, and unlike runit (which was inspired by daemontools) when run ends, it waits a second and executes run again. As with runit, if it can read a down file, then it does not start the service. [3]
To control the service, you run svc [command] services, which writes to a the named pipe control. This pipe is being managed by supervise, which uses it to send a signal to the process depending on the control value it reads. [4]
When this uses System V init, you must add svscanboot to the inittab as a respawn process.
---
runit
Executes /etc/runit/2 and if this fails, restarts it. /etc/runit/2 generally runs runsvdir on a particular directory (normally /etc/service) [5] and once every 5 seconds checks if the time of last modification, the inode, or the device has changed, in which case it starts a new runsv process on the new directory.
runsv switches to the directory of the service and if the file down doesn't exist it executes the run script. Once the script exits, if there is a finish script it executes this. If there is no finish script, then runsv executes the run script again. [6]
To handle abnormal failure, you must write a script that handles it. When the run command exits, runsv passes the exit code (-1 if abnormal exit) and least significant byte of the exit status as determined by waitpid - useful if a signal is sent. [6]
You start and stop a service by using the sv program. The mechanism used in to create a pipe named control in the service directory, which runsv reads and when a control character is written to the pipe it first checks to see if there is a custom command it needs to run, if so then it runs it. runsv will send a signal to the process it is monitoring depending on what control character is written to the pipe, or unless the custom command returns 0 in which case no signal is sent. [6]
runit is meant to replace init, and run under PID 1. [7] However, it can still use it with the existing init on your system. [8] You can configure it to replace the logging facility via the <service>/log/run script - runit just redirects the services standard output to it as standard input and you just send that input to the logger.
---
OpenRC
Not a replacement for init, but instead is invoked by init. /sbin/openrc reads /etc/runlevels, builds a dependency graph and then starts the run scripts for each of the services in the correct order. Then executable ends. [9]
---
s6
Basically inspired by runit, except the guy who makes it feels that dependency management is important and should be run by PID1. [14]
To do this, he has created a minimal shell language called execline [10] which he has run as the first process by his program execlineb [11], creates a tmpfs filesystem and copies a base image prepared by s6-linux-init into it [12], has the process reload its environment variables then forks and blocks a child process. Next, it executes as PID 1 into the service dependency tool s6-svscan, which scans a service directory and loads some initial minimal services (the logger and an optional getty, etc).
Once this is done the child process unblocks and executes s6-rc-init, which requires a compiled service database and a services directory for it to scan. After this is done, the system will be in a fully operational state.
To shutdown, PID 1 is sent a s6-svscanctl command and a shutdown script is issued.
---
In Summary
Here's the thing I see. With the exception of s6, which makes sense but seems overly complicated to me, all of these init systems have issues. daemontools polls to see if services need to be loaded, and has no dependency order. Runit has the same issue, but as pointed out by the s6 creator, if the runsv process dies then the pipe between the logger and the process means that you can lose the log. [15] s6 also does dependency by forking early, then blocking that child process till the system is usable enough for normal services to start correctly. To do this requires considerable effort, which may not be a big problem but I don't know if it's a big enough concern to be concerned about.
Runit and daemontools run shell scripts, but not in the system V way - they have run scripts you can customize. s6 has something similar, but allows for dependency tracking through listening and waiting for the status of services. You can combine Runit with OpenRC.
systemd uses socket activation for it's dependency tracking. The biggest criticism of it is that it runs in PID 1, and if it crashes it will take out your system. Whilst there are ways around this (as shown by the s6 system), I think in reality it's unlikely to occur. YMMV. But systemd provides unit files and a bunch of configurability, and I personally think it makes everyone's life easier.
The ancilliary utilities are not running in PID 1 though. And as with other systems, you use a utility to start and stop services - which some object to, but when you objectively look at it I really think you'd be hard pressed to be terribly worried about it.
So systemd does do a lot, but I think most of the arguments I've seen so far don't really show how it is a failed system in any way.
1. http://cr.yp.to/daemontools/svscanboot.html
2. http://cr.yp.to/daemontools/svscan.html
3. http://cr.yp.to/daemontools/supervise.html
4. http://cr.yp.to/daemontools/svc.html
5. http://smarden.org/runit/debian/2
6. http://smarden.org/runit/runsv.8.html
7. http://smarden.org/runit/replaceinit.html
8. http://smarden.org/runit/useinit.html
9. https://github.com/OpenRC/openrc/blob/master/guide.md
10. http://skarnet.org/software/execline/
11. http://skarnet.org/software/execline/execlineb.html
12. http://skarnet.org/software/s6-linux-init/s6-linux-init-make...
13. http://skarnet.org/software/s6-rc/s6-rc-init.html
And to them systemd is mana from heaven, as it allows them to bring up and shut down any number of nodes in their cattle farm swiftly.
Where before admins fretted about making sure a server stayed up when booted (and if it went down, make damn sure to figure out why so it didn't happen again), devops seems to adopt what i consider uptime by machinegun.
That server won't stay up for some reason? No problem. Lets just throw thousands more just like it at the task, like a machinegun throws bullets at a target.
What parts of the kernel are you referring to? Genuinely interested...
I believe in lowest common denominator everytime. Binary anything is bad when alternatives exist. Linux has given itself over to binary blobs in the name of being more attractive to corporate users. Device drivers under Linux are now almost all binary blobs. You will not see this in OpenBSD, for example. The BSD folk reverse engineer the drivers and write their own free drivers -- and they are usually far and away better afterwards.
Take the wireless chipset drivers for Ralink. The BSD guys took a 30,000 line driver and rewrote the entire thing in less than 1/3 of the code. That's just the whole attitude between Linux and BSD. Linux is a series of cobbled-together hacks on top of an ever-growing, ever-complex kernel (that really needs legacy crap removed). BSD, on the other hand, is engineered as a single OS with a small collection of pruned base programs. Big difference. If you've ever used BSD, you will know the joy of /etc/rc.conf vs the nightmare of Linux config files that live in myriad locations depending on the distro.
I'm still very curious as to what binary blobs you are referring to though.
Systemd, like a lot of things coming out of redhat these days (firewalld), feels like bloatware to me.
Systemd, Firewalld, D-Bus, etc.. have no place in a server IMHO.