Change line endings to crlf in a few cs files
This commit is contained in:
1 parent
fb8e7c5b81
commit
b03fec7f79
3 files changed
+2495
-2495
No files matched your search
@@ -1,76 +1,76 @@
|
||||
using BCG;
|
||||
|
||||
using bts;
|
||||
|
||||
using Bts.PubSub;
|
||||
using Bts.PubSubServer;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using mbts.config;
|
||||
|
||||
using Spark.Core;
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
Parser.Default.ParseArguments<PubSubServerConfig>(args)
|
||||
.MapResult(Run, errs => 1);
|
||||
|
||||
int Run(PubSubServerConfig cfg) {
|
||||
try {
|
||||
cfg.MergeWithConfigFile();
|
||||
cfg.MergeWith(PubSubServerConfig.Default());
|
||||
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
|
||||
Configuration.initialize(cfg.Sparkd);
|
||||
return cfg.SimpleEchoServer ?? false ?
|
||||
RunEchoServer(cfg.PubSub.ServerPort.assert_value()) :
|
||||
RunPubSubServer();
|
||||
} catch (Exception ex) {
|
||||
// Write the error to console first, in case the logging system is compromised.
|
||||
var error_msg = $"PubSubServer threw exception:\n{ex}";
|
||||
Console.Error.WriteLine(error_msg);
|
||||
Console.Error.Flush();
|
||||
Log.Gen.error(error_msg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int RunPubSubServer() {
|
||||
var config = PubSubConfig.Instance;
|
||||
long currentMemory = 0;
|
||||
int defaultWaitTime = 100;
|
||||
bool gced = false;
|
||||
Task.Run(() => {
|
||||
while (true) {
|
||||
gced = false;
|
||||
currentMemory = GC.GetTotalMemory(false);
|
||||
if (config.GcActivationThreshold > 0 && currentMemory > config.GcActivationThreshold) {
|
||||
Console.WriteLine($"GCing memory, mem before GC = {currentMemory}");
|
||||
GC.Collect();
|
||||
gced = true;
|
||||
}
|
||||
Thread.Sleep(gced ? config.WaitPeriodAfterGc.assert_value() : defaultWaitTime);
|
||||
}
|
||||
});
|
||||
new PubSubMessageReactor(config.ServerPort.assert_value()).start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RunEchoServer(short port) {
|
||||
Console.WriteLine("Running as TCP Echo server, Hit enter to continue");
|
||||
Console.ReadLine();
|
||||
Console.WriteLine($"ready to listen to port: {port}");
|
||||
var sts = new SimpleTCPServer(port, true);
|
||||
sts.init();
|
||||
Console.CancelKeyPress += OnCancelKeyPress;
|
||||
while (true) {
|
||||
Thread.Sleep(TimeSpan.FromSeconds(3));
|
||||
}
|
||||
|
||||
void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) {
|
||||
Log.Gen.error("Cancel key press. Disposing echo server");
|
||||
sts.Dispose();
|
||||
}
|
||||
}
|
||||
using BCG;
|
||||
|
||||
using bts;
|
||||
|
||||
using Bts.PubSub;
|
||||
using Bts.PubSubServer;
|
||||
|
||||
using CommandLine;
|
||||
|
||||
using mbts.config;
|
||||
|
||||
using Spark.Core;
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
Parser.Default.ParseArguments<PubSubServerConfig>(args)
|
||||
.MapResult(Run, errs => 1);
|
||||
|
||||
int Run(PubSubServerConfig cfg) {
|
||||
try {
|
||||
cfg.MergeWithConfigFile();
|
||||
cfg.MergeWith(PubSubServerConfig.Default());
|
||||
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
|
||||
Configuration.initialize(cfg.Sparkd);
|
||||
return cfg.SimpleEchoServer ?? false ?
|
||||
RunEchoServer(cfg.PubSub.ServerPort.assert_value()) :
|
||||
RunPubSubServer();
|
||||
} catch (Exception ex) {
|
||||
// Write the error to console first, in case the logging system is compromised.
|
||||
var error_msg = $"PubSubServer threw exception:\n{ex}";
|
||||
Console.Error.WriteLine(error_msg);
|
||||
Console.Error.Flush();
|
||||
Log.Gen.error(error_msg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int RunPubSubServer() {
|
||||
var config = PubSubConfig.Instance;
|
||||
long currentMemory = 0;
|
||||
int defaultWaitTime = 100;
|
||||
bool gced = false;
|
||||
Task.Run(() => {
|
||||
while (true) {
|
||||
gced = false;
|
||||
currentMemory = GC.GetTotalMemory(false);
|
||||
if (config.GcActivationThreshold > 0 && currentMemory > config.GcActivationThreshold) {
|
||||
Console.WriteLine($"GCing memory, mem before GC = {currentMemory}");
|
||||
GC.Collect();
|
||||
gced = true;
|
||||
}
|
||||
Thread.Sleep(gced ? config.WaitPeriodAfterGc.assert_value() : defaultWaitTime);
|
||||
}
|
||||
});
|
||||
new PubSubMessageReactor(config.ServerPort.assert_value()).start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RunEchoServer(short port) {
|
||||
Console.WriteLine("Running as TCP Echo server, Hit enter to continue");
|
||||
Console.ReadLine();
|
||||
Console.WriteLine($"ready to listen to port: {port}");
|
||||
var sts = new SimpleTCPServer(port, true);
|
||||
sts.init();
|
||||
Console.CancelKeyPress += OnCancelKeyPress;
|
||||
while (true) {
|
||||
Thread.Sleep(TimeSpan.FromSeconds(3));
|
||||
}
|
||||
|
||||
void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) {
|
||||
Log.Gen.error("Cancel key press. Disposing echo server");
|
||||
sts.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user