开发者

Resetting Application Scope on ColdFusion cluster

Is there a way t开发者_StackOverflow社区o reset the Application, via onApplicationStart, and ensure that all the servers in the cluster have their application restarted?

For example, in the current code, DSN is set in request. I would like to push it to application scope, but if there is a change that needs to be made, I would like to make sure it is propagated to all the servers in the cluster without starting and stopping CF services.


One suggestion is to have a date-stamped file in your project that each server can read.

Get CF to save the date into the application on start-up and compare what it has against that file in each onRequestStart().

If the date ever changes then CF runs the onApplicationStart() of that server.

We use that technique with our ANT scripts, so as we deploy to each server ANT timestamps the file and the next person to hit our application causes the application reset.

Cheers, James


We have our applications set up to reset their scopes via URL variable. So you could use code like this to restart the applications on all servers in your cluster via http through a page in your admin:

<cfset serverList = "Server1.domain.com,Server2.domain.com" />
<cfset threadList = "" />
<cfloop list="#serverList#" index="currentServer">
    <cfset threadList = ListAppend(threadList, "thread#currentServer#") />
    <cfthread
        action="run"
        name="thread#currentServer#"
        url="http://#currentServer#?URLToResetScope"
        key="#currentIndex#"
    >
        <cfhttp method="get" url="#Attributes.URL#" result="thread.cfhttp" />
    </cfthread>

</cfloop>
<cfthread action="join" name="#threadList#" timeout="120000" />
<cfloop list="#threadList#" index="currentThread">
    <cfset Results &= currenthThread & ": " & threadresult.cfhttp />
</cfloop>

What we're doing is taking a list of servers, then looping through that list, and with cfthread, passing off a request to each server to reset it's own scope. Then, we join all those threads together, and loop through them to get the results of each request. Then we can display those results in the admin, to make sure that all servers in the cluster got updated correctly. If there is any server that didn't get updated correctly, we can then go reset that server individually.

Dan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜