<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Courier New; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Courier New; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Courier New; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">Elliot,<BR class="Apple-interchange-newline"></SPAN></SPAN></SPAN> </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Well, I think I'm onto something.  I've been hacking on Service.pm and the code that spawns new servers.  Around line 1162 I've added a subroutine which verifies that the server is available on the specified ip and port it receives from  $self-&gt;{pool}-&gt;get_backend_endpoint.  If the server isn't there, then I execute a lot of code and return a new $ip and $port, and then let the subroutine continue.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>I'm a little concerned that this gets executed only when new backends are created, and that if an existing backend with a persistent connection goes down this code won't be executed.  I'd like to find a better place for it and write a 'hook' for it.  Essentially a 'verify' server hook.  Any ideas or suggestions would be appreciated.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>-=Raistlin</DIV><BR><DIV><DIV>On 8-Oct-06, at 12:11 PM, Elliot F wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I would suggest taking a look at the code around the backend_client_assigned hook.<SPAN class="Apple-converted-space">  </SPAN>If you haven't already, take a look at the doc/hacking/hooks.txt file.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I'm not sure, but your problem may quickly get much more complex.<SPAN class="Apple-converted-space">  </SPAN>I would not be surprised if you have to make your own hook somewhere, or modify perlbal.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If the 'backend_client_assigned' hook isn't enough, I'm assuming you would want to look at './lib/Perlbal/BackendHTTP.pm', and specifically the 'assign_client' sub around line 159.<SPAN class="Apple-converted-space">  </SPAN>I'm not saying this is the answer, but it would be where I would start looking.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Hope that helps,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Elliot</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Raistlin Majere wrote:</DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Alright, I have the plugin/callback being called.<SPAN class="Apple-converted-space">  </SPAN>Looks like I just needed to add "plugins = MyPlugin" (where MyPlugin is the package in the Perlbal/Plugin directory).</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">The callback functionality looks useful for polling things and reacting accordingly, I've implemented this, however I am curious how to rewrite a request to a different backend server.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Ideally I'd like to be able to be able to:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Accept a request to a virtualhost</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Verify that the backend server is up and running</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">if it's not then hold the request while I either:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>a) bring the backend server up</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>b) rewrite the request to a different server</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Any ideas how to redirect the request, POST data, etc to a different machine?</DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Raistlin,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Take a look at registering a callback that perlbal will trigger every N seconds.<SPAN class="Apple-converted-space">  </SPAN>AtomStream.pm has it being used.<SPAN class="Apple-converted-space">  </SPAN>It's called 'Perlbal::Socket::register_callback'.<SPAN class="Apple-converted-space">  </SPAN>You would be able to do whatever check(s) you want, and react accordingly (mark it as down somehow, reconfigure perlbal, etc.)<SPAN class="Apple-converted-space">  </SPAN>And it wouldn't be doing it for every request.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Just make sure you don't block.<SPAN class="Apple-converted-space">  </SPAN>:)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Elliot</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Raistlin Majere wrote:</DIV> <BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I've installed and configured perlbal and have run into some difficulties.<SPAN class="Apple-converted-space">  </SPAN>I've setup perlbal to be a reverse proxy so that it correctly proxies virtualhosts to the appropriate servers.<SPAN class="Apple-converted-space">  </SPAN>(i.e. vhost1.example.com, vhost2.example.com correctly reverse proxies for vhost1.com and vhost2.com respectively) This is working perfectly, and wasn't too difficult to configure.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">However now I want to write some code that will:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">First verify that the backend server is alive</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Second that the backend server can answer requests on the port I'm trying to talk to</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">And if it's NOT alive and able to respond to requests that I can redirect requests to a different server, or execute some code to bring the downed server up, before retrying.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I've tried to use the Perlbal::ClientProxy "start_proxy_request" hook, however that seems to affect each and every request (i.e. each html page, graphic, etc.)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I need to be able to check to see if the backend server is alive, and if it's not, tell Perlbal: "Whoa hold your horeses" long enough for me to bring a server up (I can do this with some scripts I have), and then redirect the request to the new server.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Any help or advice would be greatly appreciated.</DIV> </BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></DIV><BR></BODY></HTML>