Пример #1
0
        private static Grpc.Core.Server Run(string[] args,
                                            out IServiceHealth health)
        {
            Grpc.Core.Server server;

            try
            {
                MicroserverArguments arguments;
                string configFilePath;
                if (!TryGetArgumentsFromConfigFile(args, _configFileName, out arguments,
                                                   out configFilePath))
                {
                    var parsedArgs = Parser.Default.ParseArguments <MicroserverArguments>(args);

                    parsedArgs.WithParsed(a => { arguments = a; });
                }

                ConfigureLogging(arguments.VerboseLogging, _logConfigFileName);

                // Read the RuntimeUtils.Version to initialize it and use fall-back implementation
                // to avoid subsequent hang once the license has been initialized (this is probably
                // only relevant for 10.x).
                _msg.DebugFormat("Installed ArcGIS Version: {0}.", RuntimeUtils.Version);

                if (configFilePath != null)
                {
                    _msg.InfoFormat("Using service configuration defined in {0}", configFilePath);
                }
                else
                {
                    _msg.DebugFormat(
                        "Program was called with the following command line arguments: {0}{1}",
                        Environment.NewLine, arguments);
                }

                _msg.DebugFormat("Host: {0}", arguments.HostName);
                _msg.DebugFormat("Port: {0}", arguments.Port);

                _msg.InfoFormat("Checking out ArcGIS license...");

                ComUtils.ExecuteInStaThread(CheckoutLicense);

                EnvironmentUtils.SetConfigurationDirectoryProvider(
                    ConfigurationUtils.GetAppDataConfigDirectoryProvider());

                server = StartServer(arguments, out health);
            }
            catch (Exception ex)
            {
                _msg.Error("An error occurred in QA microservice startup.", ex);
                throw;
            }

            return(server);
        }