5 ms·
nothing precludes a reasonable shell library from making initscripts 10 lines long: http://cvsweb.netbsd.org/bsdweb.cgi/src/etc/rc.d/cron?rev=1.6&content-type=
by cat199 7y ago
nothing precludes a reasonable shell library from making initscripts 10 lines long:
http://cvsweb.netbsd.org/bsdweb.cgi/src/etc/rc.d/cron?rev=1.6&content-type=text/x-cvsweb-markup&only_with_tag=MAIN http://cvsweb.netbsd.org/bsdweb.cgi/src/etc/rc.d/cron?rev=1....
this does not require systemd cruft and all of it's over-opinionated facebook-youth narcissistic my-use-case is all that matters tentacles.
- CameronNemo 7y agoOpenRC is similarly concise. The runit run scripts used on Void Linux are too, but they rarely take into account complicated dependencies so they are fragile.
- theamk 7y agoAren’t you replacing systemd with run_rc_command? This is just as opinionated, but with less features. (In particular, will the error be logged if the program fails to start due to bad config file? And how do I describe “only start once “volume X” is mounted?j)
- cat199 7y ago> Aren’t you replacing systemd with run_rc_command? This is just as opinionated, but with less features. sure, but this is a 'reasonable shell library' rather than the 'systemd cruft + tentacles' that I mention. want it to do something else? write your own functions. want "an init system that can automatically restart failed services, and with decent dependency management" here you go: # cat /etc/daemoncheck #! /bin/sh docheck() { initscript="/etc/rc.d/$1"; if [ -x "$initscript" ]; then $initscript check > /dev/null \ || $initscript start fi } docheck ntpd docheck inetd docheck dhcpd docheck tftpd & throw that, or similar in cron or make it run in a while loop. Nothing precludes some rudimentary shell script being bundled as part of a simple shell-style init system out of the box. I don't need 5000 lines of C code, multiple binaries, 10 layers of symlinks, and all of the rest of it. a few hundred lines of shell that anyone who knows shell and how to read manual pages (that are kept up to date on the actual system, not bad HTML needing 10 tools to render the last time someone thought to update the documentation) can understand the entierty of in literally one sitting.
- theamk 7y agoThanks for the example -- because this is exactly why I am glad we had systemd! I do remember using the gentoo's rc system, and writing the script very much like you wrote here, and it always "kinda works". Specifically, how is "$initscript check" will work? I have seen three approaches: - Sometimes, "check" searches for the process with the given name. That can fail if you are on multi-user system, and a user runs a server on non-standard port. - Sometimes, "check" checks for .pid file, and that process with given pid exists. This can fail if you have high process churn, and your PID got reused. - Sometimes, "check" does completely strange things. Like check that PID file exists, but not the contents -- so it would work fine if you use start/stop commands, but will not notice if the server crashes. So yes, you can do it in shell, and it will work.. most of the time. And hey, you can always fix it -- the first time you discover that your server did not restart, you'd edit the script and add port checking... and then upgrade it to better kill runaway processes.. you can keep going and going. In the end, I think it all brings you back to old pets vs cattle debate. If your server is manually provisioned, each process is carefully tuned, then shell scripts are for you. If you just want to say "install something_d" and have things work, across thousands of systems, at the expense of uglier config and non-optimal file layout -- then more advanced inits are way better.
- cat199 7y agologging is covered here: https://netbsd.gw.com/cgi-bin/man-cgi?rc+8+NetBSD-current https://netbsd.gw.com/cgi-bin/man-cgi?rc+8+NetBSD-current https://netbsd.gw.com/cgi-bin/man-cgi?rc.subr+8+NetBSD-current https://netbsd.gw.com/cgi-bin/man-cgi?rc.subr+8+NetBSD-curre... and dependency ordering here: https://netbsd.gw.com/cgi-bin/man-cgi?rcorder+8+NetBSD-current https://netbsd.gw.com/cgi-bin/man-cgi?rcorder+8+NetBSD-curre... design rationale & further discussion here: Luke Mewburn, "The Design and Implementation of the NetBSD rc.d system", Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference, USENIX Association, http://www.usenix.org/publications/library/proceedings/usenix01/freenix01/full_papers/mewburn/mewburn.pdf, June 25-30, 2001.
- theamk 7y agoI can see the rc runner itself will save output to /var/run/rc.log . This is great, as far as shell-based systems go -- of course not as good as systemd/upstart (which separate by service), but better than many linux's init systems. Next, I wanted to check if "run_rc_command" suppressed the stdout/stderr of the program it was running. And here is where I hit a first difficulty: - The rc.subr manpage you referred to does not seem to mention logging it in any way. - So I looked in the source.. and it is 1300 line shell script [1], with run_rc_command being pretty complex function, with thousands of lines of code. I found answer to my question (apparently it does not care about stdout/stderr at all), but this was non-trivial. Compare it to systemd, which just have this information in the official manpages [2]. Are you still claiming shell-based init scripts are simpler? (Expert level question: you have a third-party Java app, which provides a single sh file for you to run. Can you use it with your "10 line init script"? Why not?) [1] https://github.com/IIJ-NetBSD/netbsd-src/blob/e4505e0610ceb1b2db8e2a9ed607b4bfa076aa2f/etc/rc.subr https://github.com/IIJ-NetBSD/netbsd-src/blob/e4505e0610ceb1... [2] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput= https://www.freedesktop.org/software/systemd/man/systemd.exe...