-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
79 lines (62 loc) · 2.31 KB
/
Program.cs
File metadata and controls
79 lines (62 loc) · 2.31 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Serger.SRG_Core;
using Serger.SRG_Core.Config;
namespace Serger;
public abstract class Program
{
private static Lang LoadLanguage(Config config)
{
// Load language based on config setting
var lang = Lang.LoadLang(config.Lang);
// Log the language loading
Log.PrintLog($"{lang.LanguageLoaded}: {config.Lang}");
return lang;
}
private static void Init()
{
// Initialize the configuration
var config = new Config();
// Load config first without language (will use fallback messages)
config.LoadConfig();
// Load language
var lang = LoadLanguage(config);
// Initialize the logger
Log.PrintLog($"{lang.SergerStarted} - CS Version: {config.CsVersion}, JSON Version: {config.JsonVersion}");
// Display current configuration
config.ReadConfig();
// Initialize the monitor scheduler
var scheduler = new MonitorScheduler(lang);
// Subscribe to monitor results (they are already logged by scheduler)
scheduler.MonitorResult += (_, _) => {
// Additional processing can be added here if needed
};
// Add some example monitors to config if none exist
if (config.Monitors.Count == 0)
{
config.Monitors.Add(new PingMonitor("8.8.8.8", 30000, 5000));
config.Monitors.Add(new HttpMonitor(60000, 10000, "https://www.batacek.eu", [200], null));
config.Monitors.Add(new SocketMonitor("8.8.8.8", 45000, 5000, 53));
// Save the updated config
config.SaveConfig(lang);
}
// Start monitoring
scheduler.UpdateMonitors(config.Monitors);
Log.PrintLog("Monitor scheduler started. Press Ctrl+C to exit.");
// Keep the application running
while (true)
{
Thread.Sleep(1000);
}
}
public static void Main(string[] args)
{
try
{
Init();
}
catch (Exception ex)
{
Log.WriteLog($"Fatal error: {ex.Message}");
Console.WriteLine($"Fatal error occurred. Check logs for details.");
}
}
}