]>
jfr.im git - irc/SurrealServices/srsv.git/blob - branches/erry-devel/SrSv/RunLevel.pm
1 # This file is part of SurrealServices.
3 # SurrealServices is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # SurrealServices is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with SurrealServices; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 package SrSv
::RunLevel
;
21 SrSv::RunLevel - Control system state.
27 use Exporter
'import';
35 our @EXPORT_OK = (qw($runlevel main_shutdown emerg_shutdown), keys(%constants));
36 our %EXPORT_TAGS = (levels
=> [keys(%constants)]);
38 require constant; import
constant (\
%constants);
41 # FIXME: Uncommenting this breaks $ircd_ready for some reason.
42 #use SrSv::IRCd::IO qw(ircd_disconnect);
43 use SrSv
::Process
::Worker
qw(ima_worker shutdown_all_workers kill_all_workers call_in_parent);
44 use SrSv
::Timer
'stop_timer';
46 our $runlevel = ST_NORMAL
;
49 call_in_parent
(__PACKAGE__
.'::_main_shutdown');
52 sub emerg_shutdown
() {
53 $runlevel = ST_SHUTDOWN
;
55 shutdown_all_workers
sub { exit; };
57 Event-
>timer(after
=> 5, cb
=> sub {
64 sub _main_shutdown
() {
65 ircd
::agent_quit_all
("Shutting down.");