mirror of
https://github.com/PsychoticNinjaRepo/idlerpg-ng.git
synced 2025-04-25 20:10:59 -05:00
Trap INT/TERM; add TERM signal handler; add quiting/restarting status messages
This commit is contained in:
parent
958d78e20a
commit
db48fcdab0
@ -218,6 +218,8 @@ print "\n".debug("Becoming a daemon...")."\n";
|
|||||||
daemonize();
|
daemonize();
|
||||||
|
|
||||||
$SIG{HUP} = "readconfig"; # sighup = reread config file
|
$SIG{HUP} = "readconfig"; # sighup = reread config file
|
||||||
|
$SIG{INT} = "writedb"; # sigint = force write of players database
|
||||||
|
$SIG{TERM} = "quit"; # sigterm = write db and quit game
|
||||||
|
|
||||||
CONNECT: # cheese.
|
CONNECT: # cheese.
|
||||||
|
|
||||||
@ -325,6 +327,7 @@ sub parse {
|
|||||||
sts("WHO $opts{botchan}");
|
sts("WHO $opts{botchan}");
|
||||||
(my $opcmd = $opts{botopcmd}) =~ s/%botnick%/$opts{botnick}/eg;
|
(my $opcmd = $opts{botopcmd}) =~ s/%botnick%/$opts{botnick}/eg;
|
||||||
sts($opcmd);
|
sts($opcmd);
|
||||||
|
chanmsg ("*** IdleRPG has returned ***");
|
||||||
$lasttime = time(); # start rpcheck()
|
$lasttime = time(); # start rpcheck()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -845,6 +848,8 @@ sub parse {
|
|||||||
else {
|
else {
|
||||||
$opts{reconnect} = 0;
|
$opts{reconnect} = 0;
|
||||||
writedb();
|
writedb();
|
||||||
|
chanmsg ("IdleRPG is taking a short break and shall return shortly.");
|
||||||
|
fq ();
|
||||||
sts("QUIT :DIE from $arg[0]",1);
|
sts("QUIT :DIE from $arg[0]",1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -915,6 +920,8 @@ sub parse {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
writedb();
|
writedb();
|
||||||
|
chanmsg("*** IdleRPG is restarting ***");
|
||||||
|
fq();
|
||||||
sts("QUIT :RESTART from $arg[0]",1);
|
sts("QUIT :RESTART from $arg[0]",1);
|
||||||
close($sock);
|
close($sock);
|
||||||
exec("perl $0");
|
exec("perl $0");
|
||||||
@ -2350,3 +2357,12 @@ sub readconfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# signal handler to permit sane quitting from the command line
|
||||||
|
sub quit {
|
||||||
|
$opts{reconnect} = 0;
|
||||||
|
writedb();
|
||||||
|
chanmsg ("IdleRPG is taking a short break and shall return shortly.");
|
||||||
|
fq ();
|
||||||
|
sts("QUIT :DIE from terminal",1);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user