private static void CurrentDomainProcessExit(object sender, EventArgs e) { Console.WriteLine("exit"); _server.Stop(); _server = null; _store.Dispose(); }
/// <summary> /// Stop this service. /// </summary> protected override void OnStop() { _server.Stop(); _server = null; _store.Dispose(); }
/// <summary> /// Set things in motion so your service can do its work. /// </summary> protected override void OnStart(string[] args) { NameValueCollection appSettings = ConfigurationManager.AppSettings; _port = int.Parse(appSettings["proxyPort"]); _secured = bool.Parse(appSettings["proxySecured"]); _store = new SQLiteStore("mocument"); _server = new Server(_port, _secured, _store); _server.Start(); }
public virtual void FixtureSetup() { GetMode(GetType().GetCustomAttributes(typeof(MocumentModeOverrideAttribute), true)); _mocumentDataPath = ConfigurationManager.AppSettings["mocumentDataPath"]; _mocumentDataPath = Path.GetFullPath(_mocumentDataPath); _mocumentKey = ConfigurationManager.AppSettings["mocumentKey"]; _userName = ConfigurationManager.AppSettings["apiUserName"]; _password = ConfigurationManager.AppSettings["apiPassword"]; _apiUrl = ConfigurationManager.AppSettings["apiRpcUrl"]; _streamingUrl = ConfigurationManager.AppSettings["apiStreamingUrl"]; _apiKey = ConfigurationManager.AppSettings["apiKey"]; _server = CreateServer(); }
// ReSharper disable UnusedParameter.Local private static void Main(string[] args) // ReSharper restore UnusedParameter.Local { NameValueCollection appSettings = ConfigurationManager.AppSettings; _port = int.Parse(appSettings["proxyPort"]); _secured = bool.Parse(appSettings["proxySecured"]); _proxySSLPort = int.Parse(appSettings["proxySSLPort"]); _proxyHostName = appSettings["proxyHostName"]; _store = new SQLiteStore("mocument"); AppDomain.CurrentDomain.ProcessExit += CurrentDomainProcessExit; _server = new Server(_port, _proxySSLPort, _proxyHostName, _secured, _store); Console.CancelKeyPress += ConsoleCancelKeyPress; _server.Start(); Console.WriteLine("Hit CTRL+C to end session."); bool bDone = false; do { Console.WriteLine( "\nEnter a command [G=Collect Garbage; Q=Quit]:"); Console.Write(">"); ConsoleKeyInfo cki = Console.ReadKey(); Console.WriteLine(); switch (cki.KeyChar) { case 'g': Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0")); Console.WriteLine("Begin GC..."); GC.Collect(); Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0")); break; case 'q': bDone = true; _server.Stop(); break; } } while (!bDone); }
protected void FixtureSetup() { object[] att = GetType().GetCustomAttributes(typeof(MocumentModeOverrideAttribute), true); _mocumentMode = att.Length > 0 ? ((MocumentModeOverrideAttribute)att[0]).Mode : ((MocumentMode)Enum.Parse(typeof(MocumentMode), ConfigurationManager.AppSettings["mocumentMode"], true)); switch (_mocumentMode) { case MocumentMode.Record: case MocumentMode.Play: break; default: throw new ConfigurationErrorsException("invalid Mocument.Mode. expect record or play"); } _mocumentDataPath = ConfigurationManager.AppSettings["mocumentDataPath"]; _mocumentDataPath = Path.GetFullPath(_mocumentDataPath); _mocumentKey = ConfigurationManager.AppSettings["mocumentKey"]; _userName = ConfigurationManager.AppSettings["apiUserName"]; _password = ConfigurationManager.AppSettings["apiPassword"]; _apiUrl = ConfigurationManager.AppSettings["apiRpcUrl"]; _streamingUrl = ConfigurationManager.AppSettings["apiStreamingUrl"]; _apiKey = ConfigurationManager.AppSettings["apiKey"]; _server = CreateServer(); _server.Start(); }
private Server CreateServer() { int port = Server.GetAvailablePort(32000, 33000, IPAddress.Loopback, false); IStore store = CreateStore(); var server = new Server(port, false, store); return server; }
private Server CreateServer() { int port = Server.GetAvailablePort(32000, 33000, IPAddress.Loopback, false); int sslPort = Server.GetAvailablePort(32000, 33000, IPAddress.Loopback, false, port); IStore store = CreateStore(); var server = new Server(port, sslPort, "localhost.", false, store); server.Start(); return server; }