|
Re: Writing hooks for Perlbal: msg#00002web.server.perlbal.general
Elliot, Thank you for the information, I greatly appreciate it. I apologize for my ignorance as I'm still new to Perlbal. I'm looking at AtomStream.pm at: http://code.sixapart.com/svn/perlbal/ trunk/lib/Perlbal/Plugin/AtomStream.pm and I see the snippet: Perlbal::Socket::register_callback(1, sub { my $now = time(); emit_timestamp($now) if $now > $last_timestamp; return 1; }); And from that I'm guessing I can do something along the lines create a package (like the one below (not sure if I'm even close on the structure) and place it in the Plugin directory. How would I get Perlbal to trigger my code via the plugin? Would I have to modify my perlbal.conf file? (I'm guessing I'd have to modify my service that's setup to be a selector which contains my vhosts otherwise I'd have to add it to each one of my reproxy services.) Thanks again in advance for your any help you can provide. --- package Perlbal::Plugin::TestServer.pm; use Perlbal; use strict; use warnings sub register { my ($class, $svc) = @_; Perlbal::Socket::register_callback(1, sub { my_subroutine($args); return 1; }); $svc->register_hook('TestServer', 'start_proxy_request', &my_subroutine); return 1; } sub my_subroutine { my Perlbal::ClientProxy $self = shift; my Perlbal::HTTPHeaders $hds = $self->{req_headers}; return 0 unless $hds; #psuedo code if (!backend_server_is_alive) { $hds->{headers}->{host} = "newhost: 787"; } return 1; } sub unregister { my ($class, $svc) = @_; return 1; } # called when we are loaded sub load { return 1; } # called for a global unload sub unload { return 1; } On 5-Oct-06, at 10:25 PM, Elliot F wrote: Raistlin, |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Writing hooks for Perlbal: 00002, Elliot F |
|---|---|
| Next by Date: | Re: Writing hooks for Perlbal: 00002, Raistlin Majere |
| Previous by Thread: | Re: Writing hooks for Perlbali: 00002, Elliot F |
| Next by Thread: | Re: Writing hooks for Perlbal: 00002, Raistlin Majere |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |