Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Unanswered Config Services Host: Starts two times

  • Tuesday, April 03, 2012 11:49 AM
     
     

    Hi all

    I’m hosting my config services in IIS. In the Global.asax function "Application_Start" I added the code to start the host:

    ConfigurationActions myConfigActions = newConfigurationActions();
    this.Application["MasterHost"] = ServiceConfigHelper.MasterServiceWebHost.MasterHost;

    By tracing I figured out that it's started two times. I cannot figure out where and why it's starting the second time. Any idea?

    Regards,
    Mat

All Replies

  • Wednesday, April 04, 2012 12:19 PM
    Moderator
     
     

    in global.asax for an on-premise app use:

    void Application_Start(object sender, EventArgs e)

    {
    ConfigUtility.setAzureRuntime(false);

    ConfigurationActions myConfigActions = new ConfigurationActions();
    Application["masterHost"] = ServiceConfigHelper.MasterServiceWebHost.MasterHost;
    ConfigUtility.writeConsoleMessage("\nWeb Application Global Application_Start: My Web App New Node Starting. Hello!\n", EventLogEntryType.Warning, true, new Trade.StockTraderWebApplicationSettings.Settings());
    }

     protected void Application_End(object sender, EventArgs e)
            {
                ConfigUtility.writeConsoleMessage("\nWeb Application Global Application_End: My Web App Node Shutting Down!\n", EventLogEntryType.Warning, true, new Trade.StockTraderWebApplicationSettings.Settings());
                ServiceConfigHelper.MasterServiceWebHost masterHost = (ServiceConfigHelper.MasterServiceWebHost)Application["masterHost"];
                if (masterHost != null)
                    masterHost.deActivateHosts();
                ConfigUtility.writeConsoleMessage("\nWeb Application Global Application_End: My Web App Node ShutDown COMPLETE. Goodbye!\n", EventLogEntryType.Warning, true, new Trade.StockTraderWebApplicationSettings.Settings());
            }

    Also, turn off application pool recycling for the application pool you are using using in the IIS management console-suggest you create a dedicated application pool for your app.  On start of the application pool (first request to app since app pool last started), you should see in ConfigWeb Logs--Trace Exception logs a single message indicating the start of the config services with the log entry message written in app start above.  By default, every 20 minutes an idle IIS app pool is shutdown (firing application end in global.asax), then on next request re-started, firing application start in global.asax. Turning off app pool recycling will keep the app pool active all the time.

    -Greg


    Greg Leake, Microsoft