3 ms·
sysv init scripts in particular are so pointless to write. In the end, the whole script usually revolves around four lines of actual code (starting a process,
by perlgeek 12y ago
sysv init scripts in particular are so pointless to write.
In the end, the whole script usually revolves around four lines of actual code (starting a process, stopping it, querying the status, optionally sending it a SIGHUP to make it reload its configuration), but the result is a script with 50 lines of boilerplate.
Which, of course, could nearly all be automated away by a sane, declarative format.
Leaving all the political mess aside, that's the part that systemd got right.
You write sometthing like
[Unit]
Description=some human-readable text here
[Service]
Type=simple
User=...
ExecStart=/path/to/deamon --with=options
KillSignal=SIGKILL
[Install]
WantedBy=multi-user.target
and that's it.
Quick comparison of sysv init script lengths on Debian Wheezy vs. systemd
service files on Debian Jessie: ssh: 162 vs. 15 lines, cron: 92 vs 11 lines,
dbus: 122 vs 9 lines
My point being: it's a bit too much to demand that people carefully engineer
their sysv init files, when about 90% of those very same init files is simply
boring, repetitive boiler plate code. Also, what happened to the "don't repeat
yourself" principle?
I tried writing a sysv init script from scratch. I stopped because of sheer boredom, and resorted to copy&paste to save both time and nerves.
- vezzy-fnord 12y agoThe issue isn't so much in the medium (shell), but the underlying program itself (sysvinit) being overly primitive. See the daemontools family where runscripts are largely as short or shorter than systemd unit files: http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/run-scripts-and-service-units-side-by-side.html http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/ru... In addition, the BSDs have much shorter rc scripts mainly by putting all the boilerplate functions into a single library file that is then sourced. Gentoo's OpenRC framework, as well.
- digi_owl 12y agoFranly i find myself thinking that moving the boilerplate elsewhere is also what systemd and upstart does. But those implement it in C rather than shell script.
- amyjess 12y agoNot just systemd, but... everything else that's trying to replace sysvinit, too. Upstart jobs are really simple, and OpenRC and modern BSD initscripts are also much simpler than SysV (and old BSD) initscripts. I think we're at the point where regardless of the systemd vs. everything else debate, we can all agree that SysV initscripts are shite. > I tried writing a sysv init script from scratch. I stopped because of sheer boredom, and resorted to copy&paste to save both time and nerves. Better yet, at my last job, I had some extra time, so I rewrote Ubuntu's qpidd initscript as an Upstart job, and it was so satisfying to see that giant script get condensed down to a few lines.