Inheritance: IDisposable
Esempio n. 1
0
        public static void Main(string[] args)
        {
            int port = 0;
            if (args.Length == 0)
            {
                port = 3333;
            }
            else if (args.Length == 1)
            {
                if (!int.TryParse(args[0], out port))
                {
                    Console.Error.WriteLine("Usage: flux.exe [port]");
                    Environment.Exit(1);
                }
            }
            else
            {
                Console.Error.WriteLine("Usage: flux.exe [port]");
                Environment.Exit(1);
            }

            using (var server = new Server(port))
            {
                _fixer = new Fixer(server.Start, server.Stop);

                if (Directory.EnumerateFiles(Environment.CurrentDirectory, "*.dll").Any())
                {
                    FixUpAssemblies(_fixer, "*.dll", Environment.CurrentDirectory);
                }
                else
                {
                    var bin = Path.Combine(Environment.CurrentDirectory, "bin");
                    if (Directory.Exists(bin))
                    {
                        FixUpAssemblies(_fixer, "*.dll", bin);
                    }
                    else
                    {
                        Console.Error.WriteLine("No application found in {0} or {0}\\bin", Environment.CurrentDirectory);
                        Environment.Exit(1);
                    }
                }

                Console.CancelKeyPress += ConsoleOnCancelKeyPress;
                Console.TreatControlCAsInput = false;
                _fixer.Start();
                Console.WriteLine("Flux {0}: listening on port {1}. Press CTRL-C to stop.", Assembly.GetExecutingAssembly().GetName().Version, port);
                while (!_stop)
                {
                    Console.ReadKey();
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            using (var server = new Server(8080))
            {
                server.Start(WebApp.App(new GmcJobList()));

                Console.WriteLine("Running server");
                Console.WriteLine("Press enter to exit");
                Console.ReadLine();

                server.Stop();
            }
        }