public static void Main(string[] args) { var info = VersionUtils.GetAssemblyNameInfo(); _isRequestShutdown = false; Console.Title = "ZGrid Worker"; Logger.Info($"Starting ZGrid Worker {info.Version.Major}.{info.Version.Minor}.{info.Version.MinorRevision} ({info.ProcessorArchitecture}) ..."); _gridWorker = new GridWorker(); _mainThread = new Thread(ThreadMain) { IsBackground = true }; _netThread = new Thread(ThreadNetwork) { IsBackground = true }; if (!Directory.Exists("jobs_temp")) { Directory.CreateDirectory("jobs_temp"); } try { _gridWorker.Init(); Console.Title = $"ZGrid Worker: {_gridWorker.Settings.WorkerName}"; Logger.Info("Server is initialized"); } catch (Exception e) { Logger.Error("Unable to initialize ZGrid Worker", e); return; } _mainThread.Start(); _netThread.Start(); Logger.Info("Type 'exit' to exit from application"); string input; while ((input = Console.ReadLine()) != null) { if (string.IsNullOrEmpty(input)) { continue; } if (input.Equals("exit")) { Shutdown(); return; } } }
public static void Main(string[] args) { var info = VersionUtils.GetAssemblyNameInfo(); _isRequestShutdown = false; Console.Title = "ZGrid Server"; Logger.Info($"Starting ZGrid Server {info.Version.Major}.{info.Version.Minor}.{info.Version.MinorRevision} ({info.ProcessorArchitecture}) ..."); _gridServer = new GridServer(); ConCommand.Register(_gridServer); _mainThread = new Thread(ThreadMain) { IsBackground = true }; _netThread = new Thread(ThreadNetwork) { IsBackground = true }; try { _gridServer.Init(); Logger.Info("Server is initialized"); } catch (Exception e) { Logger.Error("Unable to initialize ZGrid Server", e); return; } _mainThread.Start(); _netThread.Start(); Logger.Info("Type 'exit' to exit from application"); string input; while (!_isRequestShutdown && (input = Console.ReadLine()) != null) { if (string.IsNullOrEmpty(input)) { continue; } var cmdSelf = input.Contains(' ') ? input.Split(' ')[0] : input; var cmd = ConCommand.SearchByName(cmdSelf); if (cmd != null) { try { cmd.Execute(input.SlitToArgsFrom(1)); } catch (Exception e) { Logger.Error($"Unable to execute command {cmd.GetName()}", e); } continue; } Console.WriteLine($"Unknown command '{cmdSelf}'"); } WaitForThreadJoin(_netThread); WaitForThreadJoin(_mainThread); }