summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ee3014)
raw | patch | inline | side by side (parent: 9ee3014)
author | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Mar 2011 15:34:10 +0000 (15:34 +0000) | ||
committer | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Mar 2011 15:34:10 +0000 (15:34 +0000) |
Cleanup gosa-si-server signal handling
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20617 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20617 594d385d-05f5-0310-b6e9-bd551577e9d8
trunk/gosa-si/gosa-si-server | patch | blob | history |
index c95660b5ce4aea1257b43745b0b4c0a6a40cace4..c79bfdd1c9297b919b8121f3477987557619fb61 100755 (executable)
}
+sub clean_shutdown
+{
+ unlink($pid_file) if (-w $pid_file);
+ unlink($packages_list_under_construction) if (-w $packages_list_under_construction);
+}
-#=== FUNCTION ================================================================
-# NAME: sig_int_handler
-# PARAMETERS: signal - string - signal arose from system
-# RETURNS: nothing
-# DESCRIPTION: handels tasks to be done befor signal becomes active
-#===============================================================================
-sub sig_int_handler {
+sub sig_int_or_term_handler
+{
my ($signal) = @_;
+ daemon_log("Got SIG${signal} - shutting down gosa-si-server", 1);
+ clean_shutdown();
+ POE::Kernel->signal('gosa-si_server_session', 'KILL');
+ POE::Kernel->signal('TCP_SERVER', 'KILL');
+ return 1;
+}
-# if (defined($ldap_handle)) {
-# $ldap_handle->disconnect;
-# }
- # TODO alle verbliebenden ldap verbindungen aus allen heaps beenden
-
+sub sig_warn_handler
+{
+ my @loc = caller(0);
+ daemon_log( "SIGWARN line " . $loc[2] . ": " . $_[0], 1 );
+ return 1;
+}
- daemon_log("shutting down gosa-si-server", 1);
- system("kill `ps -C gosa-si-server -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';
sub check_key_and_xml_validity {
my ($crypted_msg, $module_key, $session_id) = @_;
}
-sub sig_handler {
- my ($kernel, $signal) = @_[KERNEL, ARG0] ;
- daemon_log("0 INFO got signal '$signal'", 1);
- $kernel->sig_handled();
- return;
-}
-
-
sub msg_to_decrypt {
my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
my $session_id = $session->ID;
sub session_start {
my ($kernel) = $_[KERNEL];
+ $kernel->alias_set('gosa-si_server_session');
$global_kernel = $kernel;
$kernel->yield('register_at_foreign_servers');
$kernel->yield('create_fai_server_db', $fai_server_tn );
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->yield('watch_for_next_tasks');
- $kernel->sig(USR1 => "sig_handler");
$kernel->sig(USR2 => "recreate_packages_db");
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
if ($opsi_enabled eq "true") {
$kernel->delay_set('watch_for_opsi_jobs', $job_queue_opsi_delay);
}
-
}
+sub session_stop {
+ my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
+ $kernel->alias_remove($heap->{alias});
+ $kernel->alarm_remove_all();
+ $kernel->post($heap->{child_session}, '_stop');
+}
sub watch_for_done_jobs {
#CHECK: $heap for what?
@@ -3498,8 +3510,8 @@ daemon_log("0 INFO: start socket for incoming xml messages at port '$server_port
POE::Session->create(
inline_states => {
_start => \&session_start,
+ _stop => \&session_stop,
register_at_foreign_servers => \®ister_at_foreign_servers,
- sig_handler => \&sig_handler,
next_task => \&next_task,
task_result => \&handle_task_result,
task_done => \&handle_task_done,