* [PATCH] daemon: re-enable SIGWINCH without setsid
@ 2016-07-29 19:17 7% Eric Wong
0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-07-29 19:17 UTC (permalink / raw)
To: meta
This allows systemd users to use SIGWINCH to temporarily
(and gracefully) stop an instance of a service without
doing a code reload to bring it back up:
# start temporary new service code
systemctl start public-inbox-nntpd@2.service
# momentarily paralyze original service
systemctl kill -s WINCH public-inbox-nntpd@1.service
if new_code_at_2_sucks
then
# restart original workers
systemctl kill -s HUP public-inbox-nntpd@1.service
else # new is better than old, replace original instance
systemctl restart public-inbox-nntpd@1.service
fi
# cleanup the temporary service
systemctl stop public-inbox-nntpd@2.service
This partially reverts commit 73d274e83b7d300f31e0cc1ceeacbf73c6c2a1e4
("daemon: disable SIGWINCH unless explicitly daemonized")
---
lib/PublicInbox/Daemon.pm | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 7849f9c..9125584 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -112,7 +112,6 @@ sub daemonize () {
check_absolute('pid-file', $pid_file);
chdir '/' or die "chdir failed: $!";
- open(STDIN, '+<', '/dev/null') or die "redirect stdin failed: $!";
return unless (defined $pid_file || defined $group || defined $user
|| $daemonize);
@@ -145,6 +144,8 @@ sub daemonize () {
die "could not fork: $!\n" unless defined $pid;
exit if $pid;
+ open(STDIN, '+<', '/dev/null') or
+ die "redirect stdin failed: $!\n";
open STDOUT, '>&STDIN' or die "redirect stdout failed: $!\n";
open STDERR, '>&STDIN' or die "redirect stderr failed: $!\n";
POSIX::setsid();
@@ -376,12 +377,12 @@ sub master_loop {
exit if $quit++;
kill_workers($s);
} elsif ($s eq 'WINCH') {
- if ($daemonize) {
- $worker_processes = 0;
- } else {
+ if (-t STDIN || -t STDOUT || -t STDERR) {
warn
"ignoring SIGWINCH since we are not daemonized\n";
$SIG{WINCH} = 'IGNORE';
+ } else {
+ $worker_processes = 0;
}
} elsif ($s eq 'HUP') {
$worker_processes = $set_workers;
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-07-29 19:17 7% [PATCH] daemon: re-enable SIGWINCH without setsid Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).