You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by ma...@sergeant.org on 2006/08/13 18:15:28 UTC
[SVN] [81] Stats console output
Revision: 81
Author: matt
Date: 2006-08-13 16:15:08 +0000 (Sun, 13 Aug 2006)
Log Message:
-----------
Stats console output
response_sent hook
Modified Paths:
--------------
trunk/lib/AxKit2/Client.pm
trunk/lib/AxKit2/Connection.pm
trunk/lib/AxKit2/Console.pm
trunk/lib/AxKit2/Plugin.pm
Modified: trunk/lib/AxKit2/Client.pm
===================================================================
--- trunk/lib/AxKit2/Client.pm 2006-08-13 02:19:05 UTC (rev 80)
+++ trunk/lib/AxKit2/Client.pm 2006-08-13 16:15:08 UTC (rev 81)
@@ -243,4 +243,18 @@
}
}
+sub hook_response_sent {
+ my $self = shift;
+ my ($ret, $out) = $self->run_hooks('response_sent', @_);
+ if ($ret == DONE) {
+ return 1;
+ }
+ elsif ($ret == DECLINED || $ret == OK) {
+ return;
+ }
+ else {
+ # TODO: errors?
+ }
+}
+
1;
Modified: trunk/lib/AxKit2/Connection.pm
===================================================================
--- trunk/lib/AxKit2/Connection.pm 2006-08-13 02:19:05 UTC (rev 80)
+++ trunk/lib/AxKit2/Connection.pm 2006-08-13 16:15:08 UTC (rev 81)
@@ -207,7 +207,12 @@
# support persistence, 0 means we're discarding this connection.
sub http_response_sent {
my AxKit2::Connection $self = $_[0];
-
+
+ if ($self->hook_response_sent($self->{headers_out}->response_code)) {
+ $self->close("plugin");
+ return 0;
+ }
+
return 0 if $self->{sock_closed};
# close if we're supposed to
Modified: trunk/lib/AxKit2/Console.pm
===================================================================
--- trunk/lib/AxKit2/Console.pm 2006-08-13 02:19:05 UTC (rev 80)
+++ trunk/lib/AxKit2/Console.pm 2006-08-13 16:15:08 UTC (rev 81)
@@ -17,7 +17,7 @@
use constant CLEANUP_TIME => 5; # seconds
-our $PROMPT = "Enter command (or \"HELP\" for help)\n";
+our $PROMPT = "\nEnter command (or \"HELP\" for help)\n> ";
Danga::Socket->AddTimer(CLEANUP_TIME, \&_do_cleanup);
@@ -118,7 +118,7 @@
}
else {
# No such method - i.e. unrecognized command
- return $self->write("command '$cmd' unrecognised\n");
+ return $self->write("command '$cmd' unrecognised\n$PROMPT");
}
}
@@ -241,7 +241,6 @@
sub DBI::FIRSTKEY {}
$helptext{leaks} = "LEAKS [DUMP] - Run Devel::GC::Helper to list leaks with optional Dumper output";
-my %prev_leaks;
sub cmd_leaks {
my $self = shift;
my $dump = shift || '';
@@ -255,6 +254,8 @@
#$Data::Dumper::Deparse = 1;
}
+ $self->write("Gathering GC stats in the background...\n");
+
my $pid = fork;
die "Can't fork" unless defined $pid;
return if $pid;
@@ -271,6 +272,33 @@
exit;
}
+$helptext{stats} = "STATS - Show status and statistics";
+sub cmd_stats {
+ my $self = shift;
+
+ my $output = "Current Status as of " . gmtime() . " GMT\n\n";
+
+ if (defined &AxKit2::Plugin::stats::get_stats) {
+ # Stats plugin is loaded
+ $output .= AxKit2::Plugin::stats->get_stats;
+ }
+
+ my $descriptors = Danga::Socket->DescriptorMap;
+
+ my $current_connections = 0;
+ my $current_dns = 0;
+ foreach my $fd (keys %$descriptors) {
+ my $pob = $descriptors->{$fd};
+ if ($pob->isa("AxKit2::Connection")) {
+ $current_connections++;
+ }
+ }
+
+ $output .= "Current Connections: $current_connections\n";
+
+ $self->write($output);
+}
+
# Cleanup routine to get rid of timed out sockets
sub _do_cleanup {
my $now = time;
Modified: trunk/lib/AxKit2/Plugin.pm
===================================================================
--- trunk/lib/AxKit2/Plugin.pm 2006-08-13 02:19:05 UTC (rev 80)
+++ trunk/lib/AxKit2/Plugin.pm 2006-08-13 16:15:08 UTC (rev 81)
@@ -10,7 +10,7 @@
our @hooks = qw(
logging config pre-connection connect post_read_request
body_data uri_translation access_control authentication authorization
- fixup mime_map xmlresponse response disconnect error
+ fixup mime_map xmlresponse response response_sent disconnect error
);
our %hooks = map { $_ => 1 } @hooks;