I'm trying to get my MG 3.2/Coldspring/Transfer app up to snuff so I can 
begin doing true continuous deployment.  I have refactored session objects 
in order to persist across service layer and framework restarts 
successfully.  I'm running very simple tests where I restart my app in one 
browser and click around in another.  I can pretty easily get Model-Glue 
(Controllers) to throw nonsense errors while it's reinitializing (meaning, 
reloading a moment later, the error doesn't occur, and it's clear by the 
error that it's an in-progress error where the controller is not fully 
initialized yet).  I also run into issues with Transfer emitting 
CacheShutdown errors although I think I have a fix for that.

How do I re-init my app's service layer and model-glue apps without letting 
a user make a request against an uninitialized framework?  Here's my setup:

* parent beanfactory setup as application.cs
* one MG app and two MG sub-apps in sub directories, call them "public", 
"subapp1" and "subapp2"
* MG 3.2
* Transfer ORM with EhCache
* My trigger "reinitfull' which restarts my beanfactory is NOT the same key 
as Model-Glue's reload; I do that based on a suggestion by Sean Corfield to 
just delete the key from the application scope which forces all three of my 
MG apps to reload simultaneously.

My Application.cfc onApplicationStart() looks like:

        <!--- create coldspring bean factory --->
        <cfset bf = createObject("component", 
"coldspring.beans.DefaultXmlBeanFactory").init() />
        <cfset 
bf.loadBeansFromXmlFile(expandPath("/PUKKA_MAIN_MAP/config/globalbeans.xml"), 
true) />
        <cfset application.cs = bf />


My OnRequestStart() looks like:


<cfif NOT structKeyExists(application, "cs") OR structKeyExists(URL, 
"reinitfull")>
    <cflock name="applicationReinit" type="exclusive" timeout="60">
        <cfif NOT structKeyExists(application, "cs") OR 
structKeyExists(URL, "reinitfull")>

            <cfset msg = "Full init called" />

            <cfinvoke component="cfide.adminapi.administrator" 
method="login">
                <cfinvokeargument name="adminPassword" value="somePassword" 
/>
            </cfinvoke>

            <!--- clear template cache --->
            <cftry>
                <cfinvoke component="cfide.adminapi.runtime" 
method="clearTrustedCache" />
                <cfset msg = listAppend(msg, "Cleared Trusted Cache") />

                <cfcatch type="any">
                    <cfset msg = listAppend(msg, "FAILED to clear Trusted 
Cache") />
                </cfcatch>
            </cftry>

            <!--- while onApplicationStart() is running, errors can be 
thrown so move the beanfactory over during shutdown --->
            <cfset bf = application.cs />

            <cfset onApplicationStart() />
            <cfset msg = listAppend(msg, "onApplicationStart(): Coldspring 
reset") />

            <!--- shutdown transfer cache to ensure memory is released --->
            <cftry>
                <cfset tf = bf.getBean('ormService') />
                <cfset tf.shutdown() />
                <cfset msg = listAppend(msg, "Transfer shutdown") />

                <cfcatch type="any">
                    <cfset msg = listAppend(msg, "Unable to clear Transfer 
cache") />
                </cfcatch>
            </cftry>

            <!--- force individual Model-Glue reloads (suggestion from Sean 
Corfield) --->
            <cfset structDelete(application, "public", false) />
            <cfset structDelete(application, "subapp1", false) />
            <cfset structDelete(application, "subapp2", false) />
            <cfset msg = listAppend(msg, "Model-Glue restarted") />

        </cfif>    
    </cflock>

    <cfif structKeyExists(application, "cs")>
        <cfset ss = application.cs.getBean('sessionService') />
        <cfset ss.getMessaging().addWarning(msg) />
    </cfif>

</cfif>


With very little load (e.g., one user) I'm able to fairly consistently 
reproduce AN error.  Rarely the same error twice because the request is 
hitting the reload at some random point in the cycle so it's always 
different.  I believe the renaming and shutdown of the Transfer cache AFTER 
restarting Coldspring (and a new instance of Transfer) has cleaned up some 
of my errors with ehCache reporting it has been shutdown.

My questions are: 

* Is this the best way to reinit? 
* Should the order be different?  E.g., delete model-glue first, then 
coldspring, then run onApplicationStart()?   
* How do other people deploy Model-Glue apps and refresh their service 
layer without interrupting end user sessions? 
* The structDelete on the Model Glue framework was recommended by Sean 
Corfield many moons ago; perhaps this is not the best way to trigger a 
reload under 3.2 or for multiple sub apps?

Thanks!


Brian

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to