public MelBoxWeb(int port) { using (var server = new RestServer()) { server.Port = PortFinder.FindNextLocalOpenPort(port); //server.UseHttps = true; server.LogToConsole(Grapevine.Interfaces.Shared.LogLevel.Warn).Start(); Console.WriteLine("WebHost:\thttp://" + server.Host + ":" + server.Port); stopWebServer.WaitOne(); server.LogToConsole().Stop(); server.ThreadSafeStop(); } }
/* Description: Start grapevine HTTP(S) server * */ public static void StartGrapevineServer() { Console.WriteLine("StartGrapevineServer() started"); try { using (var server = new RestServer()) { if (Misc.UseHTTPS) { server.UseHttps = true; } server.Port = ConfigurationManager.AppSettings.Get("HttpPort"); server.LogToConsole().Start(); while (true) { } } } catch (Exception e) { Console.WriteLine("StartGrapevineServer(): {0}", e); Console.ReadLine(); System.Environment.Exit(1); } }
public static void Main(string[] args) { using (var server = new RestServer()) { server.LogToConsole(); server.PublicFolder = new PublicFolder(@"C:\source\github\gv-gh-pages") { Prefix = "Grapevine" }; server.OnBeforeStart = () => Console.WriteLine("---------------> Starting Server"); server.OnAfterStart = () => Console.WriteLine($"<--------------- Server Started"); server.OnBeforeStop = () => Console.WriteLine("---------------> Stopping Server"); server.OnAfterStop = () => { Console.WriteLine("<--------------- Server Stopped"); Console.ReadLine(); }; server.Start(); Console.ReadLine(); server.Stop(); } }
static void Main(string[] args) { Debug.WriteLine("Started!"); ServerSettings settings = new ServerSettings(); settings.Host = "ec2-35-164-218-97.us-west-2.compute.amazonaws.com"; //93.82.35.63 //settings.Host = "localhost"; //78.104.199.75 settings.Port = "8080"; insertInitialData(); try { using (var server = new RestServer(settings)) { server.LogToConsole().Start(); //New Thread needs to be started, which calculates the market prizes and handles the orders. Thread myThread = new Thread(new ThreadStart(orderBookOperations)); myThread.Start(); Console.ReadLine(); server.Stop(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); Console.ReadLine(); } }
public static void StartRestServer(RestServer server) { bool inputValid = false; char input; while (!inputValid) { Console.WriteLine("Release or Debug? (R||D)"); input = Console.ReadKey().KeyChar; if (input == 'R' || input == 'r') { server.Host = "+"; inputValid = true; Console.WriteLine(""); } if (input == 'D' || input == 'd') { server.Host = "localhost"; inputValid = true; Console.WriteLine(""); } } server.Port = "5000"; server.LogToConsole().Start(); Console.ReadLine(); server.Stop(); }
public static void Main(string[] args) { using (var server = new RestServer()) { server.LogToConsole().Start(); Console.ReadLine(); server.Stop(); } }
public ServerManager() { ServerSettings settings = new ServerSettings(); settings.PublicFolder = new PublicFolder("./HTTP/Static"); Srv = new RestServer(settings); Srv.LogToConsole().Start(); }
static void Main(string[] args) { using (var restServer = new RestServer()) { restServer.Port = "9090"; restServer.LogToConsole().Start(); Console.ReadLine(); restServer.Stop(); } }
static void Main(string[] args) { { var v = "v0.1.0.0"; var nameService = "Load Balancer Service"; Console.Title = nameService + " " + v; Console.WriteLine(" L O A D B A L A N C E R S E R V I C E " + v); var serverStandar = new RestServer(); var input = ""; while ((input = Console.ReadLine()) != "q") { switch (input) { case "start": Console.WriteLine("Starting service..."); serverStandar.Port = "5010"; serverStandar.Host = "*"; serverStandar.Start(); Console.Title = "[ON] " + nameService + " " + v; break; case "start --log": Console.WriteLine("Starting service..."); using (var server = new RestServer()) { server.Port = "5010"; server.Host = "*"; server.LogToConsole().Start(); Console.Title = "[ON] " + nameService + " " + v; Console.ReadLine(); server.Stop(); } break; case "stop": Console.WriteLine("Stopping service..."); serverStandar.Stop(); Console.Title = nameService + " " + v; break; case "--version": Console.WriteLine(v); break; default: Console.WriteLine(String.Format("Unknown command: {0}", input)); break; } } } }
public void Start() { // Prevent double if (Server.IsListening) { return; } Server.LogToConsole().Start(); }
public void NullSetNullLogger() { using (var server = new RestServer()) { server.LogToConsole(); server.Logger.ShouldBeOfType <ConsoleLogger>(); server.Logger = null; server.Logger.ShouldBeOfType <NullLogger>(); } }
public void DoesNotSetRouterLoggerWhenRouterIsNull() { using (var server = new RestServer()) { server.Logger.ShouldBeOfType <NullLogger>(); server.Router = null; Should.NotThrow(() => server.LogToConsole()); server.Logger.ShouldBeOfType <ConsoleLogger>(); } }
public void SetsRouterLogger() { using (var server = new RestServer()) { server.Router.ShouldNotBeNull(); server.Logger.ShouldBeOfType <NullLogger>(); server.Router.Logger.ShouldBeOfType <NullLogger>(); server.LogToConsole(); server.Logger.ShouldBeOfType <ConsoleLogger>(); server.Router.Logger.ShouldBeOfType <ConsoleLogger>(); } }
static void Main(string[] args) { if (args.Where(a => a == "seed") != null) { Seed.Seed.seed(); ScheduledJobs.StatisticsJobs.run(DateTime.Parse("1970-01-01 00:00:00")); } using (RestServer server = new RestServer()) { server.LogToConsole().Start(); Console.ReadLine(); } }
public static void Main(string[] args) { using (var server = new RestServer()) { server.LogToConsole(); server.OnBeforeStart = () => server.Logger.Trace("Starting Server"); server.OnAfterStart = () => server.Logger.Trace("Server Started"); server.OnBeforeStop = () => server.Logger.Trace("Stopping Server"); server.OnAfterStop = () => server.Logger.Trace("Server Stopped"); server.Router.BeforeRouting += ctx => server.Logger.Debug("Before Routing!!"); server.Router.BeforeRouting += ctx => server.Logger.Debug("After Routing!!"); server.Start(); Console.ReadLine(); server.Stop(); } }
public Program(JObject config) { // load information about the local client Arrowhead.Utils.Settings settings = new Arrowhead.Utils.Settings(config); // creating the client registers it in the Service Register this.client = new Arrowhead.Client(settings); bool useSSL = settings.Interfaces.Any(i => i == "HTTPS-SECURE-JSON"); using (var server = new RestServer()) { server.UseHttps = useSSL; server.Host = config.SelectToken("system.ip").ToString(); server.Port = config.SelectToken("system.port").ToString(); server.LogToConsole().Start(); Console.ReadLine(); server.Stop(); } }
static void RunWebServer(CancellationToken token) { if (token.IsCancellationRequested) { Console.WriteLine("Web-Server beendet."); return; } using (var server = new RestServer()) { server.Port = Port; server.LogToConsole(Grapevine.Interfaces.Shared.LogLevel.Warn).Start(); while (!token.IsCancellationRequested) { //nichts unternehmen } //server.LogToConsole().Stop(); server.Stop(); } }
static void Main(string[] args) { if (args.Length != 4) { Console.WriteLine("Missing parameters ..."); Console.WriteLine("Usage: ProtectedLog.exe activityFile precedenceFile sequenceFile privacyBudget"); Console.WriteLine("Example: ProtectedLog.exe log-activities.csv log-precedence.csv log-sequences.csv 10.0"); Console.ReadKey(); return; } var activityFile = args[0]; var precedenceFile = args[1]; var sequenceFile = args[2]; var privacyBudget = Double.Parse(args[3], new CultureInfo("en")); Agent = new PINQAgentObservableBudget(privacyBudget); ActToId = cc.Read <ActivityEntry>(activityFile, inputFileDescription).ToDictionary(a => a.Activity, a => a.Id); IdToAct = cc.Read <ActivityEntry>(activityFile, inputFileDescription).ToDictionary(a => a.Id, a => a.Activity); var activities = ActToId.Select(a => a.Key).ToArray(); Relations = activities.SelectMany(x => activities.Select(y => x + "," + y)).ToArray(); wrapPrecedenceTable(precedenceFile); wrapSequenceTable(sequenceFile); /**** Data is now sealed up. Use from this point on is unrestricted ****/ using (var server = new RestServer()) { server.LogToConsole().Start(); Console.WriteLine("Type 'exit' to stop server!"); var line = Console.ReadLine(); while (line != "exit") { line = Console.ReadLine(); } server.Stop(); } }
public static void Main(string[] args) { Clientes = new List <Cliente>(); string loHost = string.IsNullOrEmpty(ConfigurationManager.AppSettings["Host"]) ? "localhost" : ConfigurationManager.AppSettings["Host"]; string loPort = string.IsNullOrEmpty(ConfigurationManager.AppSettings["Port"]) ? "1234" : ConfigurationManager.AppSettings["Port"]; Server = new RestServer(new ServerSettings() { Host = loHost, Port = loPort }); Server.LogToConsole().Start(); while (Server.IsListening) { Thread.Sleep(300); } Console.WriteLine("Pressione Enter para continuar..."); Console.ReadLine(); }
static void Main(string[] args) { if (config.Inventory.LoadNodesOnStartUp) { Console.WriteLine("Loading Inventory..."); inventoryClient.LoadInventory(); } using (var server = new RestServer()) { server.Host = config.RESTServerConfig.Host; server.Port = config.RESTServerConfig.Port.ToString(); server.Advanced.AuthenticationSchemes = System.Net.AuthenticationSchemes.Basic; server.LogToConsole().Start(); if (config.Inventory.LoadNodesOnStartUp) { Console.WriteLine("Connecting Inventory..."); inventoryClient.ConnectInventory(); // Inventory Reload InventoryReloadTimer.Elapsed += (s, ea) => { inventoryClient.LoadInventory(); inventoryClient.ConnectInventory(); }; InventoryReloadTimer.Enabled = true; } Console.ReadLine(); server.Stop(); Console.WriteLine("Disconnecting Inventory..."); InventoryReloadTimer.Enabled = false; inventoryClient.DisconnectInventory(); } }
static void Main(string[] args) { Metric.Config .WithHttpEndpoint("http://localhost:8888/") .WithAllCounters(); Console.CancelKeyPress += (s, ev) => { Console.WriteLine("[CTRL]+[C] pressed!"); ev.Cancel = true; }; var host = "+"; var port = "1234"; using (var server = new RestServer()) { server.Port = port; server.Host = host; server.LogToConsole().Start(); Console.ReadLine(); server.Stop(); } }
static void Main(string[] args) { Debug.WriteLine("Started!"); ServerSettings settings = new ServerSettings(); settings.Host = "ec2-35-164-218-97.us-west-2.compute.amazonaws.com"; //93.82.35.63 //settings.Host = "localhost"; //78.104.199.75 settings.Port = "8080"; insertInitialData(); try { using (var server = new RestServer(settings)) { server.LogToConsole().Start(); Console.ReadLine(); server.Stop(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); Console.ReadLine(); } }
public API() { server = new RestServer(); server.Host = "+"; server.LogToConsole().Start(); }
static void Main(string[] args) { using (var server = new RestServer()) { #region Metrics Server var metricServer = new MetricServer(port: 60000); metricServer.Start(); #endregion #region SHIFT YGGRDASIL2 igp_topology = new Topology.IGP.Topology(); mpls_topology = new Topology.MPLS.Topology(); ConcurrentQueue <JObject> igp_topology_changes_queue = new ConcurrentQueue <JObject>(); // IGP Topology Buffer bool igp_topology_task_enabled = false; ConcurrentQueue <JObject> mpls_topology_changes_queue = new ConcurrentQueue <JObject>(); // MPLS Topology Buffer bool mpls_topology_task_enabled = false; // Messaging Messaging.ControlQueue cq = new Messaging.ControlQueue( brokerHostname: config.MessageBrokerHostname, brokerPort: config.MessageBrokerPort, brokerUsername: config.MessageBrokerUsername, brokerPassword: config.MessageBrokerPassword, routingKey: config.ControlQueueRoutingKey ); Messaging.IGP.TopologyQueue tq_igp = new Messaging.IGP.TopologyQueue( brokerHostname: config.MessageBrokerHostname, brokerPort: config.MessageBrokerPort, brokerUsername: config.MessageBrokerUsername, brokerPassword: config.MessageBrokerPassword, routingKey: config.IGPTopologyQueueRoutingKey ); Messaging.MPLS.TopologyQueue tq_mpls = new Messaging.MPLS.TopologyQueue( brokerHostname: config.MessageBrokerHostname, brokerPort: config.MessageBrokerPort, brokerUsername: config.MessageBrokerUsername, brokerPassword: config.MessageBrokerPassword, routingKey: config.MPLSTopologyQueueRoutingKey ); Messaging.PerformanceQueue pq = new Messaging.PerformanceQueue( brokerHostname: config.MessageBrokerHostname, brokerPort: config.MessageBrokerPort, brokerUsername: config.MessageBrokerUsername, brokerPassword: config.MessageBrokerPassword, routingKey: config.PerformanceQueueRoutingKey ); Messaging.NodePCCQueue nq = new Messaging.NodePCCQueue( brokerHostname: config.MessageBrokerHostname, brokerPort: config.MessageBrokerPort, brokerUsername: config.MessageBrokerUsername, brokerPassword: config.MessageBrokerPassword, routingKey: config.NodePCCQueueRoutingKey ); IntentQueueProducer = new Messaging.IntentQueueProducer( brokerHostname: config.MessageBrokerHostname, brokerPort: config.MessageBrokerPort, brokerUsername: config.MessageBrokerUsername, brokerPassword: config.MessageBrokerPassword, routingKey: config.IntentQueueRoutingKey ); #endregion #region SHIFT BACKEND CONNECTION // Messaging // Intent Queue IntentQueueProducer.Connect(); // IGP Topology Queue Task var igp_topology_queue_task = new Task(() => { while (igp_topology_task_enabled) { while (!igp_topology_changes_queue.IsEmpty) { if (igp_topology_changes_queue.TryDequeue(out JObject data)) { // Console.WriteLine("Topology Change: " + data); igp_topology.Update(data); } } Thread.Sleep(10); } }, TaskCreationOptions.LongRunning); // MPLS Topology Queue Task var mpls_topology_queue_task = new Task(() => { while (mpls_topology_task_enabled) { while (!mpls_topology_changes_queue.IsEmpty) { if (mpls_topology_changes_queue.TryDequeue(out JObject data)) { // Console.WriteLine("Topology Change: " + data); mpls_topology.Update(data); MPLSHierarchicalLabelSwitchedPaths.Set(mpls_topology.HierarchicalLabelSwitchedPaths.Count); } } Thread.Sleep(10); } }, TaskCreationOptions.LongRunning); // Control Queue Event Setup cq.OnStartCallback += (routing_key) => { // IGP Topology Queue tq_igp.RoutingKey = routing_key; tq_igp.Connect(); // MPLS Topology Queue tq_mpls.Connect(); // Performance Queue pq.Connect(); // Node PCC Queue nq.Connect(); // Setup Topology Events igp_topology.OnNodeUpdateCallback += Igp_topology_OnNodeUpdateCallback; igp_topology.OnLinkUpdateCallback += Igp_topology_OnLinkUpdateCallback; igp_topology.OnLinkUpCallback += Igp_topology_OnLinkUpCallback; igp_topology.OnLinkDownCallback += Igp_topology_OnLinkDownCallback; // Load Topology data.Neo4J Neo4J = new data.Neo4J { Neo4J_URI = config.Neo4J_URI, Neo4J_User = config.Neo4J_User, Neo4J_Password = config.Neo4J_Password }; Neo4J.LoadIGPTopology(igp_topology); mpls_topology = Neo4J.LoadMPLSTopology(); MPLSHierarchicalLabelSwitchedPaths.Set(mpls_topology.HierarchicalLabelSwitchedPaths.Count); // Start Processing IGP Topology Changes Queue igp_topology_task_enabled = true; igp_topology_queue_task.Start(); // Start Processing MPLS Topology Changes Queue mpls_topology_task_enabled = true; mpls_topology_queue_task.Start(); }; cq.OnTopologyQueueChangeCallback += (routing_key) => { // Stop Processing Topology Changes Queue igp_topology_task_enabled = false; while (igp_topology_queue_task.Status == TaskStatus.Running) { Thread.Sleep(100); } // IGP Topology Queue tq_igp.RoutingKey = routing_key; tq_igp.Connect(); // Setup Topology Events igp_topology.OnNodeUpdateCallback += Igp_topology_OnNodeUpdateCallback; igp_topology.OnLinkUpdateCallback += Igp_topology_OnLinkUpdateCallback; igp_topology.OnLinkUpCallback += Igp_topology_OnLinkUpCallback; igp_topology.OnLinkDownCallback += Igp_topology_OnLinkDownCallback; // Load Topology data.Neo4J Neo4J = new data.Neo4J { Neo4J_URI = config.Neo4J_URI, Neo4J_User = config.Neo4J_User, Neo4J_Password = config.Neo4J_Password }; Neo4J.LoadIGPTopology(igp_topology); mpls_topology = Neo4J.LoadMPLSTopology(); MPLSHierarchicalLabelSwitchedPaths.Set(mpls_topology.HierarchicalLabelSwitchedPaths.Count); // Start Processing Topology Changes Queue igp_topology_task_enabled = true; igp_topology_queue_task.Start(); }; // IGP Topology Queue Event Setup tq_igp.OnTopologyChangeCallback += (data) => { // Enqueue Topology Change igp_topology_changes_queue.Enqueue(data); }; // MPLS Topology Queue Event Setup tq_mpls.OnTopologyChangeCallback += (data) => { // Enqueue Topology Change mpls_topology_changes_queue.Enqueue(data); }; // Performance Queue Event Setup pq.OnPerformanceUpdateCallback += (data) => { // Console.WriteLine("Performance Update: " + data); igp_topology.Update(data); }; // Node PCC Queue Event Setup nq.OnNodePCCUpdateCallback += (data) => { // Console.WriteLine("Node PCC Update: " + data); igp_topology.Update(data); }; // Control Queue Connect cq.Connect(); #endregion #region Scheduler Scheduler = new Scheduler(igp_topology, config); Scheduler.OnIntentDueCallback += Scheduler_OnIntentDueCallback; #endregion #region REST SERVER server.Host = "+"; server.Port = "8375"; server.LogToConsole().Start(); Console.WriteLine("Server Started."); string cmd = Console.ReadLine(); while (cmd != "exit") { Console.WriteLine("Command not found."); Console.Write("> "); cmd = Console.ReadLine(); } server.Stop(); #endregion #region SHIFT BACKEND DISCONNECT IntentQueueProducer.Disconnect(); cq.Disconnect(); tq_igp.Disconnect(); tq_mpls.Disconnect(); pq.Disconnect(); nq.Disconnect(); #endregion } }