Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the better way to restart a daemontools service?

You've pushed a code update to a daemontools service and want to restart it so it picks up the changes. The service itself is simple and has no built-in signal handling. Which way is better?

  1. svc -d; sleep 5; svc -u
    Sends TERM and then CONT. Waits for the service to actually exit, and then restarts it.
  2. svc -h
    Sends a HUP signal. The process will die on reception of the signal, and daemontools will restart it.

I've always done some variation on the first, but somebody pointed out today we could actually do the HUP just as well, and I like that better, but I've been doing it the other way so long I can't remember if there was a reason.

I thought it might be because a process in uninterruptible sleep waiting on I/O ignores signals, but according to wikipedia, "When the process is sleeping uninterruptibly, signals accumulated during the sleep will be noticed when the process returns from the system call or trap."

Anybody have an informed opinion on best practice?

like image 814
Kevin G. Avatar asked Jan 20 '26 22:01

Kevin G.


1 Answers

It would appear that option 2 (sending a HUP signal) is somewhat cleaner, but in the end, both will get the job done and neither is inherently superior.

like image 138
Perry Avatar answered Jan 23 '26 12:01

Perry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!