Last change
on this file since 7877 was
7371,
checked in by spimming, 13 years ago
|
#1680:
- start diagnostic monitor only when a connection string is specified
- constants file added
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Net;
|
---|
3 | using System.Threading;
|
---|
4 | using HeuristicLab.Clients.Hive.SlaveCore;
|
---|
5 | using Microsoft.WindowsAzure.Diagnostics;
|
---|
6 | using Microsoft.WindowsAzure.ServiceRuntime;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Clients.Hive.Slave.AzureClient {
|
---|
9 | public class WorkerRole : RoleEntryPoint {
|
---|
10 | private Core core;
|
---|
11 | private Thread coreThread;
|
---|
12 |
|
---|
13 | public override void Run() {
|
---|
14 | core = new Core(false);
|
---|
15 | coreThread = new Thread(core.Start);
|
---|
16 | coreThread.Start();
|
---|
17 |
|
---|
18 | while (true) {
|
---|
19 | Thread.Sleep(10000);
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 | public override bool OnStart() {
|
---|
24 | ServicePointManager.DefaultConnectionLimit = 12;
|
---|
25 | core = new Core();
|
---|
26 | try {
|
---|
27 | if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) {
|
---|
28 | DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
|
---|
29 | dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
|
---|
30 | dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
|
---|
31 | DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc);
|
---|
32 | }
|
---|
33 | }
|
---|
34 | catch (RoleEnvironmentException ex) {
|
---|
35 | //diagnostics connectio string not in configuration
|
---|
36 | //-> diagnostics disabled
|
---|
37 | //nothing more to do
|
---|
38 | }
|
---|
39 |
|
---|
40 | return base.OnStart();
|
---|
41 | }
|
---|
42 |
|
---|
43 | public override void OnStop() {
|
---|
44 | core.Shutdown();
|
---|
45 | base.OnStop();
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.