private void button1_Click(object sender, EventArgs e) { if (m_Server != null) { return; } // System.Threading.ThreadPool.SetMaxThreads(1024, 1024); m_Server = new WaveServer(); m_Server.Configure(null); try { // m_Server.Prefixes.Add(tbPrefix.Text); // m_Server.KernelHttpQueueLimit = 1;//0000; // m_Server.ParallelAccepts = 2; m_Server.Start(); } catch { m_Server.Dispose(); m_Server = null; throw; } }
static void Main(string[] args) { // System.Threading.ThreadPool.SetMaxThreads(3000, 3000); // System.Threading.ThreadPool.SetMinThreads(256, 256); int wt, ct; System.Threading.ThreadPool.GetAvailableThreads(out wt, out ct); Console.WriteLine("Worker: {0} Completion: {1}", wt, ct); try { using (new ServiceBaseApplication(args, null)) using (var ws = new WaveServer()) { ws.Configure(null); ws.IgnoreClientWriteErrors = false; ws.Start(); Console.WriteLine("Web server started. Press <ENTER> to terminate..."); Console.ReadLine(); } } catch (Exception error) { Console.WriteLine("Exception leaked"); Console.WriteLine("----------------"); Console.WriteLine(error.ToMessageWithType()); System.Environment.ExitCode = -1; } }
private void button2_Click(object sender, EventArgs e) { if (m_Server == null) { return; } m_Server.Dispose(); m_Server = null; }
public void Prologue(Runner runner, FID id) { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("-------------------------------------------"); Console.WriteLine("Run as Administrator or grant all users rights to http://localhost:9871"); Console.WriteLine("-------------------------------------------"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); m_Client = new HttpClient(); var config = typeof(ServerTestsBase).GetText("tests.laconf").AsLaconicConfig(handling: Data.ConvertErrorHandling.Throw); m_App = new AzosApplication(null, config); m_Server = new WaveServer(m_App); m_Server.Configure(null); m_Server.Start(); DoPrologue(runner, id); }
static void Main(string[] args) { try { using (var app = new ServiceBaseApplication(args, null)) using (var server = new WaveServer()) { server.Configure(null); server.Start(); Console.WriteLine("server started..."); Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine("Critical error:"); Console.WriteLine(ex); Environment.ExitCode = -1; } }
void Run(string[] args) { using (var wave = new WaveServer()) { wave.Configure(null); wave.Start(); ConsoleUtils.Info("Wave server prefixes:"); foreach (var prefix in wave.Prefixes) { ConsoleUtils.Info(" " + prefix); } ConsoleUtils.Info("Glue servers:"); foreach (var service in App.Glue.Servers) { ConsoleUtils.Info(" " + service); } Console.Write("Press [ENTER] to exit..."); Console.ReadLine(); } }
static void Main(string[] args) { try { using (new ServiceBaseApplication(args, null)) using (var ws = new WaveServer()) { ws.Configure(null); ws.Start(); Console.WriteLine("Web server started. Press <ENTER> to terminate..."); Console.ReadLine(); } } catch (Exception error) { Console.WriteLine("Exception leaked"); Console.WriteLine("----------------"); Console.WriteLine(error.ToMessageWithType()); System.Environment.ExitCode = -1; } }
static void Main(string[] args) { Console.WriteLine("Привет это тест!"); try { using (var app = new ServiceBaseApplication(args, null)) using (var server = new WaveServer()) { server.Configure(null); server.Start(); Console.WriteLine("Севрер запущен"); Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine("Ошибка"); Console.WriteLine(ex); Environment.ExitCode = -1; Console.ReadLine(); } }
private static int runServer(AzosApplication app) { var config = app.CommandArgs; ConsoleUtils.WriteMarkupContent(typeof(TvProgramBody).GetText("Welcome.txt")); if (config["?"].Exists || config["h"].Exists || config["help"].Exists) { ConsoleUtils.WriteMarkupContent(typeof(TvProgramBody).GetText("Help.txt")); return(0); } using (var web = new WaveServer(app)) { web.Configure(null); web.Start(); ConsoleUtils.Info("{0} start time".Args(DateTime.UtcNow)); Console.WriteLine("Server is listening on:"); web.Prefixes.ForEach(p => Console.WriteLine(" {0}".Args(p))); Console.WriteLine(); Console.WriteLine("Strike <ENTER> to terminate ..."); new Azos.Log.Sinks.ConsoleSink((Azos.Log.Sinks.ISinkOwner)app.Log, "con", 0) { Colored = true }.Start(); Console.ReadLine(); Console.WriteLine("...terminating"); Console.WriteLine(); } return(0); }
protected override void DoInitApplication() { base.DoInitApplication(); var FROM = GetType().FullName + ".DoInitApplication()"; var metabase = m_BootLoader.Metabase; try { m_GDIDProvider = new GdidGenerator(this, "Sky"); foreach (var ah in metabase.GDIDAuthorities) { m_GDIDProvider.AuthorityHosts.Register(ah); WriteLog(MessageType.Info, FROM + "{GDIDProvider init}", "Registered GDID authority host: " + ah.ToString()); } WriteLog(MessageType.Info, FROM, "GDIProvider made"); } catch (Exception error) { WriteLog(MessageType.CatastrophicError, FROM + "{GDIDProvider init}", error.ToMessageWithType()); try { m_GDIDProvider.Dispose(); } catch { } m_GDIDProvider = null; } var wmSection = ConfigRoot[CONFIG_WEB_MANAGER_SECTION]; if (wmSection.Exists && wmSection.AttrByName(CONFIG_ENABLED_ATTR).ValueAsBool(false)) { try { m_WebManagerServer = new WaveServer(this); m_WebManagerServer.Configure(wmSection); m_WebManagerServer.Start(); } catch (Exception error) { WriteLog(MessageType.CatastrophicError, FROM + "{WebManagerServer start}", error.ToMessageWithType()); try { m_WebManagerServer.Dispose(); } catch {} m_WebManagerServer = null; } } var lockSection = ConfigRoot[CONFIG_LOCK_MANAGER_SECTION]; try { m_LockManager = FactoryUtils.MakeAndConfigure <ILockManagerImplementation>(lockSection, typeof(LockManager)); WriteLog(MessageType.Info, FROM, "Lock Manager made"); if (m_LockManager is Daemon) { ((Daemon)m_LockManager).Start(); WriteLog(MessageType.Info, FROM, "Lock Manager STARTED"); } } catch (Exception error) { WriteLog(MessageType.CatastrophicError, FROM + "{LockManager start}", error.ToMessageWithType()); try { m_LockManager.Dispose(); } catch {} m_LockManager = null; } var procSection = ConfigRoot[CONFIG_PROCESS_MANAGER_SECTION]; try { m_ProcessManager = FactoryUtils.MakeAndConfigure <IProcessManagerImplementation>(procSection, typeof(ProcessManager), new object[] { this }); WriteLog(MessageType.Info, FROM, "Process Manager made"); if (m_ProcessManager is Daemon) { ((Daemon)m_ProcessManager).Start(); WriteLog(MessageType.Info, FROM, "Process Manager STARTED"); } } catch (Exception error) { WriteLog(MessageType.CatastrophicError, FROM + "{ProcessManager start}", error.ToMessageWithType()); try { m_ProcessManager.Dispose(); } catch {} m_ProcessManager = null; } var hostSection = ConfigRoot[CONFIG_HOST_MANAGER_SECTION]; try { m_DynamicHostManager = FactoryUtils.MakeAndConfigure <IHostManagerImplementation>(procSection, typeof(HostManager), new object[] { this }); WriteLog(MessageType.Info, FROM, "Dynamic Host Manager made"); if (m_DynamicHostManager is Daemon) { ((Daemon)m_DynamicHostManager).Start(); WriteLog(MessageType.Info, FROM, "Dynamic Host Manager STARTED"); } } catch (Exception error) { WriteLog(MessageType.CatastrophicError, FROM + "{HostManager start}", error.ToMessageWithType()); try { m_DynamicHostManager.Dispose(); } catch {} m_DynamicHostManager = null; } }
static void run(string[] args) { const string FROM = "AWS.Program"; using (var app = new SkyApplication(SystemApplicationType.WebServer, args, null)) { try { using (var wwwServer = new WaveServer(app, app.MetabaseApplicationName)) { wwwServer.Configure(null); wwwServer.Start(); try { // WARNING: Do not modify what this program reads/writes from/to standard IO streams because // AHGOV uses those particular string messages for its protocol Console.WriteLine("OK."); //<-- AHGOV protocol, AHGOV waits for this token to assess startup situation ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Welcome.txt")); Console.WriteLine("Waiting for line to terminate..."); var abortableConsole = new TerminalUtils.AbortableLineReader(); try { while (app.Active) { if (abortableConsole.Line != null) { app.Log.Write(new Message { Type = MessageType.Info, Topic = SysConsts.LOG_TOPIC_WWW, From = FROM, Text = "Main loop received CR|LF. Exiting..." }); break; //<-- AHGOV protocol, AHGOV sends a <CRLF> when it is time to shut down } Thread.Sleep(250); } } finally { abortableConsole.Abort(); } } finally { wwwServer.WaitForCompleteStop(); } } } catch (Exception error) { app.Log.Write(new Message { Type = MessageType.CatastrophicError, Topic = SysConsts.LOG_TOPIC_WWW, From = FROM, Text = "Exception leaked in run(): " + error.ToMessageWithType(), Exception = error }); throw error; } }//using app }
public static void run(string[] args) { ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Welcome.txt")); ConsoleUtils.Info("Running on a `{0}` platform".Args(NFX.PAL.PlatformAbstractionLayer.PlatformName)); Console.WriteLine("Init app container..."); //////System.Threading.ThreadPool.SetMaxThreads(1000, 1000); using (var app = new ServiceBaseApplication(args, null)) { Console.WriteLine("...app container is up"); var cmd = app.CommandArgs.AttrByIndex(0).Value; if (app.CommandArgs["?"].Exists || app.CommandArgs["h"].Exists || app.CommandArgs["help"].Exists) { ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Help.txt")); return; } ConsoleUtils.Info("Glue servers:"); var any = false; foreach (var s in App.Glue.Servers) { Console.WriteLine(" " + s); any = true; } if (!any) { Console.WriteLine(" - No servers"); } Console.WriteLine(); if (cmd.EqualsOrdIgnoreCase("machine")) { MachineSpeed.CRC32(); } else if (cmd.EqualsOrdIgnoreCase("slim")) { SlimSpeed.SerDeserSimpleObject(); SlimSpeed.SerDeserPerson(); SlimSpeed.SerDeserPersonArray(); } else if (cmd.EqualsOrdIgnoreCase("echo")) { var node = app.CommandArgs.AttrByIndex(1).ValueAsString() ?? "sync://127.0.0.1:8000"; var count = app.CommandArgs["c"].AttrByIndex(0).ValueAsInt(1000); //count of requests var par = app.CommandArgs["p"].AttrByIndex(0).ValueAsInt(1); //max degree of parallelism // GlueSpeed.Echo(node, count, par); GlueSpeed.EchoThreaded(node, count, par); } else if (cmd.EqualsOrdIgnoreCase("pile")) { var threads = app.CommandArgs["t"].AttrByIndex(0).ValueAsInt(4); var count = app.CommandArgs["c"].AttrByIndex(0).ValueAsInt(20_000_000); var size = app.CommandArgs["sz"].AttrByIndex(0).ValueAsInt(32); PileSpeed.ProfileByteArray(threads, count, size); PileSpeed.ProfileString(threads, count, size); PileSpeed.ProfileSimpleObject(threads, count); PileSpeed.ProfilePersonObject(threads, count); } else if (cmd.EqualsOrdIgnoreCase("wave")) { using (var ws = new WaveServer()) { ws.Configure(null); ws.IgnoreClientWriteErrors = false; ws.Start(); Console.WriteLine("Web server started"); Console.WriteLine("Strike <ENTER> to terminate web server "); Console.ReadLine(); } } Console.WriteLine("Strike <ENTER> to exit app"); Console.ReadLine(); Console.WriteLine("Shutting app container..."); } Console.WriteLine("...app container is disposed"); }