Пример #1
0
        public override void OnStop()
        {
            this.telemetry.TrackTrace("WorkerRole stopping", SeverityLevel.Information);

            try
            {
                this.stopEvent.Set();

                if (this.settingsWatcher != null)
                {
                    this.settingsWatcher.Dispose();
                    this.settingsWatcher = null;
                }

                if (this.trainProcesserHost != null)
                {
                    this.trainProcesserHost.Dispose();
                    this.trainProcesserHost = null;
                }

                if (this.webApp != null)
                {
                    this.webApp.Dispose();
                    this.webApp = null;
                }

                base.OnStop();
            }
            catch (Exception e)
            {
                this.telemetry.TrackException(e);
            }

            this.telemetry.TrackTrace("WorkerRole stopped", SeverityLevel.Information);
        }
Пример #2
0
        public override bool OnStart()
        {
            try
            {
                // Set the maximum number of concurrent connections
                ServicePointManager.DefaultConnectionLimit = 128;

                // For information on handling configuration changes
                // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

                bool result = base.OnStart();

                TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("APPINSIGHTS_INSTRUMENTATIONKEY");
                //TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
                this.telemetry = new TelemetryClient();

                try
                {
                    this.telemetry.TrackTrace("WorkerRole starting", SeverityLevel.Information);

                    this.trainProcesserHost = new LearnEventProcessorHost();
                    this.settingsWatcher    = new OnlineTrainerSettingsWatcher(this.trainProcesserHost);

                    this.StartRESTAdminEndpoint();
                }
                catch (Exception e)
                {
                    this.telemetry.TrackException(e);
                    // still start to give AppInsights a chance to log
                }
                return(result);
            }
            catch (Exception e)
            {
                Debugger.Log(1, "ERROR", $"VowpalWabbit.AzureWorker failed to start: {e.Message} {e.StackTrace}");
                throw;
            }
        }