-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
62 lines (55 loc) · 1.81 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.IO;
using NewRelic.Platform.Sdk;
namespace Org.BeyondComputing.NewRelic.HyperV
{
class Program
{
static int Main(string[] args)
{
try
{
// Validate Config Files
CheckConfigFiles();
// Start New Relic Plugin
Runner runner = new Runner();
runner.Add(new PluginAgentFactory());
runner.SetupAndRun();
}
catch (Exception e)
{
Console.WriteLine("Exception occurred, unable to continue.\nMessage: {0}", e.Message);
return -1;
}
return 0;
}
/// <summary>
/// Checks for existence of config files when starting up
/// Helps debug issues. The default New Relic SDK error isn't helpful
/// </summary>
/// <returns></returns>
private static bool CheckConfigFiles()
{
Console.WriteLine("Checking if config Files exist");
/// Check for newrelic.json file - Holds NewRelic license configuration
if (File.Exists("config/newrelic.json"))
{
Console.WriteLine("newrelic.json file exists");
}
else
{
throw new FileNotFoundException("newrelic.json file not found!");
}
/// Check for plugin.json file - Holds plugin settings
if (File.Exists("config/plugin.json"))
{
Console.WriteLine("plugin.json file exists");
}
else
{
throw new FileNotFoundException("plugin.json file not found!");
}
return true;
}
}
}