예제 #1
0
        public static void InitLog()
        {
            var xmlDocument = new XmlDocument();

            try
            {
                if (Os.IsWindows())
                {
                    xmlDocument.Load(File.OpenRead(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) +
                                                   "\\log4net.config"));
                }
                else
                {
                    xmlDocument.Load(File.OpenRead(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) +
                                                   "/log4net.config"));
                }
            }
            catch (Exception)
            {
                if (Os.IsWindows())
                {
                    xmlDocument.Load(File.OpenRead(
                                         Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log4net.config"));
                }
                else
                {
                    xmlDocument.Load(File.OpenRead(
                                         Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/log4net.config"));
                }
            }

            XmlConfigurator.Configure(
                LogManager.CreateRepository(Assembly.GetEntryAssembly(),
                                            typeof(log4net.Repository.Hierarchy.Hierarchy)), xmlDocument["log4net"]);
        }
예제 #2
0
        private static void Main()
        {
            #region config
            _config = new ConfigurationBuilder()
                      .AddJsonFile("appsettings.json", true, true)
                      .AddEnvironmentVariables()
                      .Build();
            #endregion

            #region logging

            Utils.InitLog();
            _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

            #endregion

            ArtifactPath = _config["artifactPath"];
            _gRpcHost    = _config["gRpcHost"];
            _gRpcPort    = Convert.ToInt32(_config["gRpcPort"]);

            GitId        = _config["gitId"];
            _gitPwd      = _config["gitPwd"];
            ReadOnlyMode = Convert.ToBoolean(_config["readOnlyMode"]);

            FolderSeparator = Os.IsWindows() ? "\\" : "/";
            Latest          = FolderSeparator + "latest";

            ModelManager.Init();

            _apiServer = new Server
            {
                Services = { Service.BindService(new Host()) },
                Ports    = { new ServerPort(_gRpcHost, _gRpcPort, ServerCredentials.Insecure) }
            };
            _log.Info("TaxonomyService listening on: " + _gRpcHost + " Port: " + _gRpcPort);

            _apiServer.Start();
            _log.Info("Api open on host: " + _gRpcHost + " port: " + _gRpcPort);
            Console.WriteLine("Taxonomy Ready");
            var exitEvent = new ManualResetEvent(false);

            Console.CancelKeyPress += (sender, eventArgs) => {
                eventArgs.Cancel = true;
                exitEvent.Set();
            };

            Console.WriteLine("Press \'^C\' to close the Taxonomy.Service");

            exitEvent.WaitOne();
            _apiServer.ShutdownAsync();
        }