News for hackers. Stuff that matters.
Re:Writing systemd units that stop gracefully before shutdown by LukeShu on Wednesday October 26, 2022 @06:39PM (#33350562)
> It shouldn't be this hard to stop a service gracefully.

It's not.

> you just need to drop a script into /etc/init.d symlink it from the appropriate rc directories.

You just need to drop a unit file into /etc/systemd/system/ and symlink it from the appropriate /etc/systemd/system/${target}.wants/ directories.

A lot of the article is about ordering of dependencies (don't stop a dependency until after the dependent has stopped). `Before=` and `After=` lines in the unit file is easier than manually having to remember all of the dependencies and manually figuring out the correct "NN" for it all to work correctly.

A lot of the article is about either having your daemon handle SIGTERM, or coming up with the appropriate `ExecStop=` command. The same command you'd be writing in your rc script (the "handle SIGTERM" stuff being for if your rc script simply says `kill $PID`).

That is: The complex parts of the article are things that were complex with sysvinit too.

Re:Writing systemd units that stop gracefully before shutdown by ivan23178 on Wednesday October 26, 2022 @08:23PM (#33351436)
There's also middle ground. OpenRC doesn't need those weird numbers while still being simple sysvinit/bash scripts-based system (it has a simple dependency system too). I'm not completely sure about `shutdown` level scripts having access to network though (too lazy to check), but it's still worth mentioning here.
Re:Writing systemd units that stop gracefully before shutdown by LukeShu on Wednesday October 26, 2022 @09:50PM (#33352030)
OpenRC's great! But it doesn't detract from the point that systemd isn't nearly as complicated as some people act like it is.

PS: Who's still using OpenRC with heavy ol' sysvinit instead of the lighter openrc-init?