예제 #1
0
파일: Server.cs 프로젝트: zhouzu/RestDb
        static void Main(string[] args)
        {
            #region Process-Arguments

            if (args != null && args.Length > 0)
            {
                foreach (string curr in args)
                {
                    if (curr.Equals("setup"))
                    {
                        new Setup();
                    }
                }
            }

            #endregion

            #region Load-Configuration

            if (!Common.FileExists("System.Json"))
            {
                new Setup();
            }

            _Settings = Settings.FromFile("System.Json");

            #endregion

            #region Initialize-Globals

            _Logging = new LoggingModule(
                _Settings.Logging.ServerIp,
                _Settings.Logging.ServerPort,
                _Settings.Logging.ConsoleLogging,
                (LoggingModule.Severity)_Settings.Logging.MinimumLevel,
                false,
                true,
                true,
                false,
                true,
                false);

            _Databases = new DatabaseManager(_Settings, _Logging);

            _Auth = new AuthManager(_Settings, _Logging);

            Console.WriteLine(Logo());

            _Server = new Server(
                _Settings.Server.ListenerHostname,
                _Settings.Server.ListenerPort,
                _Settings.Server.Ssl,
                DefaultRoute);

            string header = "http";
            if (_Settings.Server.Ssl)
            {
                header += "s";
            }
            header += "://" + _Settings.Server.ListenerHostname + ":" + _Settings.Server.ListenerPort;
            Console.WriteLine("Listening for requests on " + header);

            #endregion

            Terminator.WaitOne();
        }
예제 #2
0
파일: Server.cs 프로젝트: jchristn/RestDb
        static void Main(string[] args)
        {
            _Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            #region Process-Arguments

            if (args != null && args.Length > 0)
            {
                foreach (string curr in args)
                {
                    if (curr.Equals("setup"))
                    {
                        new Setup();
                    }
                }
            }

            #endregion

            #region Load-Configuration

            if (!File.Exists("./system.json"))
            {
                new Setup();
            }

            _Settings = Settings.FromFile("./system.json");

            #endregion

            #region Initialize-Globals

            Welcome();

            _Logging = new LoggingModule(
                _Settings.Logging.ServerIp,
                _Settings.Logging.ServerPort,
                _Settings.Logging.ConsoleLogging);

            _Logging.Settings.MinimumSeverity = (Severity)_Settings.Logging.MinimumLevel;

            _Databases = new DatabaseManager(_Settings, _Logging);

            _Auth = new AuthManager(_Settings, _Logging);

            _Server = new Server(
                _Settings.Server.ListenerHostname,
                _Settings.Server.ListenerPort,
                _Settings.Server.Ssl,
                DefaultRoute);

            _Server.Start();

            string header = "http";
            if (_Settings.Server.Ssl)
            {
                header += "s";
            }
            header += "://" + _Settings.Server.ListenerHostname + ":" + _Settings.Server.ListenerPort;
            Console.WriteLine("Listening for requests on " + header);

            #endregion

            Terminator.WaitOne();
        }