Skip to content
Snippets Groups Projects
Commit b309d786 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Initialize CPU monitoring in service constructor.

parent a4c27589
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,26 @@ namespace ATxService
LoadSettings();
CreateIncomingDirectories();
try {
_cpu = new Cpu {
Interval = 250,
Limit = _config.MaxCpuUsage,
Probation = 16,
Enabled = true
};
}
catch (UnauthorizedAccessException ex) {
Log.Error("Not enough permissions to monitor the CPU load.\nMake sure the " +
"service account is a member of the [Performance Monitor Users] " +
"system group.\nError message was: {0}", ex.Message);
throw;
}
catch (Exception ex) {
Log.Error("Unexpected error initializing CPU monitoring: {0}", ex.Message);
throw;
}
if (_config.DebugRoboSharp) {
Debugger.Instance.DebugMessageEvent += HandleDebugMessage;
Log.Debug("Enabled RoboSharp debug logging.");
......@@ -386,26 +406,6 @@ namespace ATxService
throw;
}
try {
_cpu = new Cpu {
Interval = 250,
Limit = 25,
Probation = 16,
Enabled = true
};
}
catch (UnauthorizedAccessException ex) {
Log.Error("Not enough permissions to monitor the CPU load.\nMake sure the " +
"service account is a member of the [Performance Monitor Users] " +
"system group.\nError message was: {0}", ex.Message);
throw;
}
catch (Exception ex) {
Log.Error("Unexpected error initializing CPU monitoring: {0}", ex.Message);
throw;
}
// read the build timestamp from the resources:
var buildTimestamp = Properties.Resources.BuildDate.Trim();
var buildCommitName = Properties.Resources.BuildCommit.Trim();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment