Author: TomdeMan
Related Categories:
ColdFusion, Coldbox
July 17, 2008
I was using the Coldbox SES interceptor and the built in Coldcourse integration, and ran into a little snag the other day. Our production boxes are clustered behind a load balancer using sticky sessions. In order to, reinitialize the framework, I had to access each host by ip and port.
This causes an issue with the current integration with Coldcourse and the SES interceptor. What happens is your BaseURL gets set to 'http://localhost:1234'. Which is no good for those rewrites, since the address will not resolve.
The answer...
Use the config or environments.xml to specify a new setting 'BaseHostName'.
config.xml
environments.xml
<Setting name="BaseHostName" value="mysite.local" />
While you are in the config, make sure you check the order of your interceptors. You will want the environment interceptor to come before the SES. Be sure to set the FireOnInit property to TRUE. This means that the load up of settings occurs once the interceptor get's created and NOT on the execution point.
<Property name='configFile'>config/environments.xml.cfm</Property>
<Property name='fireOnInit'>true</Property>
</Interceptor>
<Interceptor class="coldbox.system.interceptors.ses">
<Property name="configFile">config/routes.cfm</Property>
</Interceptor>
Then, modify the routes.cfm to accept the new setting.
<cfset setSetting('BaseHostName',cgi.HTTP_HOST) />
</cfif>
<cfif len(getSetting("AppMapping")) lte 1>
<cfset setBaseURL("http://#getSetting('BaseHostName')#")>
<cfelse>
<cfset setBaseURL("http://#getSetting('BaseHostName')#/#getSetting('AppMapping')#/index.cfm") />
</cfif>
That's it. Now whether you are clustered or not, you have control over the host name. Maybe this will make it into a future release of Coldbox.





Comments:
[Add Comment]
Rob Gonda says:
Would that allow you to reinitialize the framework on all nodes with a simple url var? You would need to do that for production releases, I suggest you look into JMS to accomplish that. JMS would be useful anyways to clear out Transfer cache across clustered nodes, good thing to have available.
7/17/08 6:07 PM
[Add Comment]