summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 307ca60)
raw | patch | inline | side by side (parent: 307ca60)
author | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Mar 2011 15:33:54 +0000 (15:33 +0000) | ||
committer | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Mar 2011 15:33:54 +0000 (15:33 +0000) |
Cleanup gosa-si-client signal handling
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20614 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20614 594d385d-05f5-0310-b6e9-bd551577e9d8
trunk/gosa-si/gosa-si-client | patch | blob | history |
index 481ea3e1e5b42c4bd5af358fd31e0263afe3dd90..57f26167185cc5de16e051bec86d3a27d3c87161 100755 (executable)
}
}
+sub clean_shutdown
+{
+ unlink($pid_file) if (-w $pid_file);
+ unlink($gosa_si_client_fifo) if (-S $gosa_si_client_fifo);
+}
-sub sig_int_handler {
+sub sig_int_or_term_handler
+{
my ($signal) = @_;
+ daemon_log("Got SIG${signal} - shutting down gosa-si-client", 1);
+ clean_shutdown();
+ POE::Kernel->signal('client_session', 'KILL');
+ POE::Kernel->signal('gosa-si-client', 'KILL');
+ return 1;
+}
+
+sub sig_warn_handler
+{
+ my @loc = caller(0);
+ daemon_log( "SIGWARN line " . $loc[2] . ": " . $_[0], 1 );
+ return 1;
+}
- daemon_log("shutting down gosa-si-client", 1);
- system("kill `ps -C gosa-si-client -o pid=`");
+sub sig_die_handler
+{
+ my @loc = caller(0);
+ daemon_log( "SIGDIE line " . $loc[2] . ": " . $_[0], 1 );
+ clean_shutdown();
+ return 1;
}
-$SIG{INT} = \&sig_int_handler;
+$SIG{'INT'} = \&sig_int_or_term_handler;
+$SIG{'TERM'} = \&sig_int_or_term_handler;
+$SIG{'__WARN__'} = \&sig_warn_handler;
+$SIG{'__DIE__'} = \&sig_die_handler;
+$SIG{'USR1'} = 'IGNORE';
+$SIG{'USR2'} = 'IGNORE';
#=== FUNCTION ================================================================
# NAME: logging
last;
# delivery of registration msg failed
- } else {
- # wait 1 sec until trying to register again
- sleep(1);
- next;
+ } elsif($REGISTRATION_TRIES >= scalar(@servers)) {
+ last;
}
} # end of while
}
-sub sig_handler {
- my ($kernel, $signal) = @_[KERNEL, ARG0] ;
- daemon_log("0 INFO got signal '$signal'", 1);
- $kernel->sig_handled();
- return;
-}
-
-
sub _start {
my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->alias_set('client_session');
$global_kernel = $kernel; # this is used to throw events at each point of the skript
- $kernel->sig(USR1 => "sig_handler");
-
# force a registration at a gosa-si-server
$kernel->yield('register_at_gosa_si_server');
}
+sub _stop {
+ my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
+ delete $heap->{'services'};
+ delete $heap->{'watchers'};
+ $kernel->alias_remove($heap->{alias});
+ $kernel->alarm_remove_all();
+ $kernel->post($heap->{child_session}, '_stop');
+}
+
+
sub _default {
daemon_log("ERROR: can not handle incoming msg with header '$_[ARG0]'", 1);
return;
POE::Session->create(
inline_states => {
_start => \&_start,
+ _stop => \&_stop,
_default => \&_default,
- sig_handler => \&sig_handler,
register_at_gosa_si_server => \®ister_at_gosa_si_server,
# trigger periodical tasks