users@glassfish.java.net

Re: Any way to change a Listener port on the fly?

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 17 Sep 2007 10:19:05 -0400

Hi,

glassfish_at_javadesktop.org wrote:
> I have an application running solely on Glassfish.
>
> The problem is that when I need to do maintenance on the site, the site is effectively dead and gives error messages to the users.
>
> So, as a remedy, I was thinking that I would set up a simple Apache instance configured for port 80.
>
> Then, I'd shutdown my Glassfish server, and then bring up Apache with its "Down for maintenance, back soon" page.
>
> But my problem then is that I can't redeploy my app and test it, since Glassfish is tied to port 80 as well.
>
> What I'd like to be able to do is change the port from 80 to, say, 8080, then I can deploy and what not, and smoke test the application through 8080. When I'm happy, I'll bring down Apache, and switch GF over to 80.
>
> Ideally, my plan would look like this.
>
> <ul>
> <li>Glassfish running on port 80.</li>
> <li>On the fly move of GF from 80 to 8080.</li>
> <li>Start up Apache on 80.</li>
> <li>redpeploy, reconfigure, bounce GF as necessary</li>
> <li>Restart GF in "production" mode on 8080</li>
> <li>down Apache</li>
> <li>Switch GF to 80</li>
> <li>Live happily ever after</li>
> </ul>
>
> I'd like to do an on the fly port move because GF can have noticably start and stop time. If I can swtich ports on the fly, then the switchover is based on apache's start up and shut down time (which is minimal).
>
> I didn't notice any asadmin commands that will let me change listener ports.
>
> How are other folks handling this?

Here is a possible solution, without you having to neither use Apache or
event restart GlassFish :-)

(1) Using admin-gui/cli [1], disable the http-listener listening on port
80. You need to set the 'enable' attribute

<http-listener acceptor-threads="1" address="0.0.0.0"
blocking-enabled="false" default-virtual-server="server" enabled="true"

enabled = false.

All requests to port 80 will get a connection refused.

*OR* you might leave port 80 open and instead, disable the
virtual-server (which is what you want I think):

<virtual-server hosts="${com.sun.aas.hostName}"
http-listeners="http-listener-1,http-listener-2" id="server"
log-file="${com.sun.aas.instanceRoot}/logs/server.log" state="disabled">

state = "disable"

All requests to port 80 will return:

> HTTP request sent, awaiting response...
> 1 HTTP/1.1 403 The virtual-server server has been disabled
> 2 X-Powered-By: Servlet/2.5
> 3 Server: Sun Java System Application Server 9.1
> 4 Content-Type: text/html; charset=iso-8859-1
> 5 Date: Mon, 17 Sep 2007 14:14:37 GMT
> 6 Connection: close
> 10:14:37 ERROR 403: The virtual-server server has been disabled.


(2) Using admin-gui/cli, creates a new http-listener on port 8080 and a
new virtual-server, deploy your app on it.

(3) Disable (or delete) the http-listener on port 80, then update the
http-listened listening on 8080 to listen to to port 80.

That's it!

-- Jeanfrancois

[1]
http://weblogs.java.net/blog/jfarcand/archive/2006/06/dynamically_add.html








>
> Any hints?
> [Message sent by forum member 'whartung' (whartung)]
>
> http://forums.java.net/jive/thread.jspa?messageID=235531
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>