Skip to main content
Participant
May 4, 2009
Question

Is it possible to start the CF8 server monitor programmatically?

  • May 4, 2009
  • 1 reply
  • 1839 views

We are using the alert feature of the CF8 server monitor to automatically restart the CF8 service if it becomes unresponsive.

Since restarting CF8 will also kill the server monitor, is there any way to start the server monitor automatically right after CF8 restarts?

Thank you in advance for your ideas!

    This topic has been closed for replies.

    1 reply

    Charlie Arehart
    Community Expert
    Community Expert
    May 4, 2009

    @kit001, the answer would be no. The alert feature runs from within CF itself: if it goes down, the Alert process goes down with it. It's natural, of course, to assume the Server Monitor is somehow external to CF, but it really isn't. The Flex App itself is, sure, but it's just exposing info you create and enable that's managed from within CF itself (turning on alerts, turning on/off the "start" buttons, etc.)

    If CF goes down, the alert mechanism can't detect that the server's gone down. That's just not its job: indeed, you'll notice there's no such alert available. It can only monitor things about the server while it stays up.

    Some may think, "well, might this be the job of the Multiserver monitor?" Again, no it's not. The Multiserver monitor is just another flex app that can watch what's going on inside any of the CF servers it's told to watch. It doesn't, itself, have any power to trigger events, restarts, etc.

    Bottom line: to have CF restart, something outside of it must restart it. (Note that on Windows, the Services feature has an option to cause a service to restart if it goes down.)

    Finally, you had asked, "is there any way to start the server monitor automatically right after CF8 restarts". Again, no. First, as stated above, the server monitor is not itself something separate from CF (except in being a Flex interface). More to the point, the alert feature is part of the monitor built into CF.

    But someone may read this as asking if there's a way to do the equivalent of the "start monitoring" button (offered in the Server Monitor) so that it's enabled "automatically right after CF8 restarts." Well, the Start buttons are toggles which, once enabled, always cause CF to in fact do the selected monitoring/profiling/memory tracking immediately upon startup. You don't need to "turn them on", if you've already done so while the server was up.

    But again: they don't have anything to do with restarting CF. You really have to rely on other tools for that.

    For any readers interested, I have a 4-part series on the CF 8 Server Monitor in the Adobe Dev Center. More at:

    http://www.carehart.org/blog/client/index.cfm/2008/7/30/45page_server_monitor_guide

    Hope that's helpful.

    /charlie

    PS I can also offer consulting or training assistance, for as little time as may be needed, in working with the Server Monitor or other monitoring and troubleshooting tools for CF.

    /Charlie (troubleshooter, carehart. org)
    kit001Author
    Participant
    May 4, 2009

    Hi Charlie,

    It is my honor to receive the first response from you! I must thank you for the outstanding articles and posts about the CF8 Server Monitor. We were not even aware of the CF8 Server Monitor before finding your articles through Google!

    There were several instances at our production server that the "Unresponsive Alert" was not able to recover CF8 by killing threads alone. The only way is to restart CF8. Here is how we set up the CF8 server monitor to restart CF8 using the “unresponsive” alert feature (i.e. cfexecute a restart batch file):

    1. Create a file named cfrestart.bat at ColdFusion8\bin:

    @Echo off

    setlocal

    cd ..\runtime\bin

    jrun -stop coldfusion

    jrun -start coldfusion

    endlocal

    2. Create a file named selfRestart.cfc at ColdFusion8\runtime\bin:

    <cfcomponent>

        <cffunction name="onAlertStart">

                <cfargument name="instruct" required="No">

                <cfset pathToCmd = "c:\windows\system32\cmd.exe">

                <cfset pathToBat = "c:\coldfusion8\bin\cfrestart.bat">           

                <cfexecute name="#pathToCmd#" arguments="/C #pathToBat#" timeout="0"></cfexecute>

            <cfreturn>   

        </cffunction>

    </cfcomponent>

    3. Under Alerts tab at CF8 Server Monitor, select Unresponsive Server tab. Check Enable and type selfRestart.cfc under Processing CFC. Click Apply.

    I have tested by triggering selfRestart.cfc via the "Slow Server" alert and CF8 was restarted successfully. I assume it will work the same for "Unresponsive Server" alert.

    If there is a way to programmatically start the CF8 server monitor after CF8 restarts, our server can theoretically run 24x7 without any manual restarts.

    Thanks again!

    Kit

    Charlie Arehart
    Community Expert
    Community Expert
    May 5, 2009

    First, thanks for your kind regards, Kit.

    Second, I see I misread your note. I thought you were asking how to restart CF from within the monitor. And while I said there's no built-in provision for that, I see that you used the feature to have Alerts trigger a CFC to call a restart script. OK.

    Third, well, you still are asking "If there is a way to programmatically start the CF8 server monitor after CF8 restarts". I did explain that the server monitor does start immediately. The "start" buttons remain enabled over CF restarts (something that does indeed surprise many, especially if they enable the "start memory tracking" and it crashes their machine, and then a restart keeps it enabled so it crashes again.)

    That should be the answer to your question, as I sense somehow you missed it. Let us know.

    All that said, I'd like to offer a different thought on your just killing the server whenever there are hung requests. Would you like instead to find out and resolve the root cause for the unresponsive server?

    Sure, some may say "we don't have time for diagnostics. We need to get the server back up and running immediately", but there are plenty of apps where there's a lot of pain in just crashing the server.

    Now, one may say, "but if it's become responsive, what choice do we have?". But you do have choices, really, and there are features in the monitor that can help you find and resolve the root cause of the problem instead.

    First, you note that you couldn't kill requests. That can certainly happen if a request is doing a tag like CFQUERY or CFHTTP (anything talking to something outside of CF).These can't be interrupted so the request can't be killed. So you need to know what the request that's hung is doing, to get to the root cause of the problem.

    Bringing down the server only masks the root cause of the problem. It's like firing a cashier each time there's money missing from the register, when a recording might catch that it's the manager skimming the till.

    So you need to be able to "zoom the camera" in on the request to find out what it's doing. Fortunately, the Server monitor helps you in either of two ways: automatically or manually.

    First, since the unresponsive server alert detects when requests that are not responding, that's when you have a problem. And if you choose to enable that a "snapshot" be triggered by the alert, it shows you details about all requests that are running. And in the "thread dump" at the bottom of the snapshot you can find the CF (JRPP) threads that are associated with CF requests.

    Second, you can see a stack trace for an individual request if you enable start profiling, and then double-click on the request while it's running.

    Either way, the stack trace will show what line of CFML code is being executed at the time the stack trace is requested. And if you view a couple of them within a short period of time, that can tell you if the request is indeed hung (waiting on some one tag to run) or may really just be working really hard and it needs time to finish.

    Hope that helps.

    /charlie

    /Charlie (troubleshooter, carehart. org)