Author: spadkins
Date: Tue Mar 18 11:06:15 2008
New Revision: 10939
Modified:
p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm
Log:
working version of the shop_time_limit feature. tested and ready to go to
production whenever we are comfortable putting it in place.
Modified: p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm (original)
+++ p5ee/trunk/App-Context/lib/App/Context/POE/Server.pm Tue Mar 18
11:06:15 2008
@@ -67,7 +67,7 @@
_start _stop _default poe_sigchld poe_sigterm poe_sigignore
poe_shutdown poe_alarm
ikc_register ikc_unregister ikc_shutdown
poe_run_event poe_event_loop_extension
poe_dispatch_pending_async_events
- poe_server_state poe_http_server_state poe_http_test_run
+ poe_server_state poe_http_server_state poe_debug poe_http_debug
poe_http_test_run
poe_enqueue_async_event poe_enqueue_async_event_finished
poe_remote_async_event_finished
)];
$self->{poe_ikc_published_states} = [qw(
@@ -128,11 +128,12 @@
'ADDRESS' => INADDR_ANY,
'PORT' => $self->{options}{http_port},
'HANDLERS' => [
+ { 'DIR' => '/debug', 'SESSION' => $session_name, 'EVENT' =>
'poe_http_debug', },
{ 'DIR' => '/testrun', 'SESSION' => $session_name, 'EVENT' =>
'poe_http_test_run', },
{ 'DIR' => '.*', 'SESSION' => $session_name, 'EVENT' =>
'poe_http_server_state', },
],
);
- $self->log({level=>3},"Listening for HTTP Requests on
$self->{host}:$self->{options}{http_port}\n") if
$self->{options}{poe_http_debug};
+ $self->log({level=>3},"Listening for HTTP Requests on
$self->{host}:$self->{options}{http_port}\n") if $self->{options}{poe_trace};
&App::sub_exit() if ($App::trace);
}
@@ -391,6 +392,20 @@
return $state;
}
+sub debug {
+ &App::sub_entry if ($App::trace);
+ my ($self) = @_;
+
+ my $datetime = time2str("%Y-%m-%d %H:%M:%S", time());
+ my $debug = "DEBUG --- Server: $self->{host}:$self->{port}
procs[$self->{num_procs}/$self->{max_procs}:max]
async_events[$self->{num_async_events}/$self->{max_async_events}:max]\n[$datetime]\n";
+ $debug .= "\n";
+ my $service = $self->{main_service};
+ $debug .= $service->debug();
+
+ &App::sub_exit($debug) if ($App::trace);
+ return($debug);
+}
+
# TODO: Implement this as a fork() or a context-level message to a node to
fork().
# i.e. messages such as "EVENT:" and "EVENT-OK:"
# Save the callback_event according to an event_token.
@@ -1159,6 +1174,36 @@
return RC_OK;
}
+sub poe_debug {
+ &App::sub_entry if ($App::trace);
+ my ( $self, $kernel, $heap ) = @_[ OBJECT, KERNEL, HEAP ];
+ $self->log({level=>3},"POE: poe_debug enter\n") if
$self->{options}{poe_trace};
+
+ my $debug = $self->debug();
+
+ $self->log({level=>3},"POE: poe_debug exit\n") if
$self->{options}{poe_trace};
+ &App::sub_exit($debug) if ($App::trace);
+ return $debug;
+}
+
+sub poe_http_debug {
+ &App::sub_entry if ($App::trace);
+ my ( $self, $kernel, $heap, $request, $response ) = @_[ OBJECT, KERNEL,
HEAP, ARG0, ARG1 ];
+ $self->log({level=>3},"POE: poe_http_debug enter\n");
+
+ my $debug = $kernel->call( $self->{poe_session_name}, 'poe_debug' );
+ ### Build the response.
+ $response->code(RC_OK);
+ $response->push_header( "Content-Type", "text/plain" );
+ $response->content($debug);
+ ### Signal that the request was handled okay.
+ $kernel->post( $self->{poe_kernel_http_name}, 'DONE', $response );
+
+ $self->log({level=>3},"POE: poe_http_debug exit\n") if
$self->{options}{poe_trace};
+ &App::sub_exit(RC_OK) if ($App::trace);
+ return RC_OK;
+}
+
sub poe_http_test_run {
&App::sub_entry if ($App::trace);
my ( $self, $kernel, $heap, $request, $response ) = @_[ OBJECT, KERNEL,
HEAP, ARG0, ARG1 ];