73 points

That’s why you launch them through systemd.

permalink
report
reply
71 points

But systemd is the devil and makes nothing better, right?

Right?

permalink
report
parent
reply
17 points

Really? I’ve never had issue with it

permalink
report
parent
reply
34 points

It’s a joke about the criticism systemd gets

permalink
report
parent
reply
8 points

openrc exists

permalink
report
parent
reply
23 points

Openrc is bloat, you should manually pair electrons

permalink
report
parent
reply
8 points

The constant nagging by you systemd people worked. I’ve written a unit that does what I need it to do. That was more annoying than I think it needed to be, but well… my solution didn’t work at all.

permalink
report
parent
reply
5 points

AFAIK kernel itself doesn’t send any signals to processes on shutdown/reboot, it just stops executing them. This is a job service manager (e.g. systemd) that terminates processes using SIGTERM before asking kernel to shutdown.

permalink
report
parent
reply
42 points
*

You are never guaranteed to be able to do anything during a crash. You are better off handling these kinds of edge cases in a recovery phase during the start of your app.

permalink
report
reply
24 points

It’s not a crash. It’s a graceful shutdown. I expected that to also shutdown my app gracefully.

I’m actually trying to store the program state that hasn’t been persisted yet to disk. Good luck doing that after the next boot.

permalink
report
parent
reply
4 points

Persist everything to disk in real time. When the signal hits exit immediately.

permalink
report
parent
reply
7 points

Persist everything to disk in real time.

That’s the thing I’m trying to avoid.

permalink
report
parent
reply
3 points
*

Crash-only software. To be resilient you need some kind of ACID anyway which means that you can let go of your shutdown procedure and just send yourself SIGKILL instead.

permalink
report
parent
reply
28 points

This is legitimately the best usage of this meme I’ve seen in years. Termination signals hnnngg

permalink
report
reply
7 points

Can’t SIGTERM be observed to react to a poweroff?

permalink
report
reply
3 points

That’s what I thought, but my program never receives the signal.

permalink
report
parent
reply
2 points

That might be an issue with who invokes your program.

permalink
report
parent
reply
7 points
*

How are you running your script?

(I have no idea how to solve your issue I’m just asking questions to sound smart and helpful)

permalink
report
reply
8 points

It’s a node process invoked by a run.sh, which gets executed via a .desktop file in the ~/.config/autostart directory.

I went with a systemd unit now and it works.

permalink
report
parent
reply
8 points
*

I can’t remember off the top of my head, but your shell script might not be relaying the SIGTERM. Make sure you start your node process with the “exec” statement. This will replace the script’s process with node instead of having node be a subprocess of your script.

permalink
report
parent
reply
3 points

When I run the script myself and kill it, it gets the signal and acts correctly. Only when I poweroff the system, this doesn’t work.

I also tried prepending exec, but no dice.

permalink
report
parent
reply
3 points

“SyStEmD iS bLoAt…”

permalink
report
parent
reply
1 point

Your DE may be the one not relaying the sigterm, or it may be losing the PID because of the double launching.

Does the LSB have something to call on termination? Or you may want to call an executable there instead of a script.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 3.6K

    Monthly active users

  • 1.1K

    Posts

  • 39K

    Comments