public static bool TryGetArgumentsFromConfigFile(string[] args, string configFileName, out MicroserverArguments arguments, out string configFilePath) { arguments = null; configFilePath = null; if (args.Length == 0) { _msg.InfoFormat("Getting server host/port parameters from configuration file."); configFilePath = GetConfigFilePath(configFileName, false); if (configFilePath != null) { XmlSerializationHelper <MicroserverArguments> helper = new XmlSerializationHelper <MicroserverArguments>(); arguments = helper.ReadFromFile(configFilePath); return(true); } } return(false); }
private static Grpc.Core.Server StartServer([NotNull] MicroserverArguments arguments, out IServiceHealth health) { // TODO: Move to ProSuite var healthService = new HealthServiceImpl(); health = null; // new ServiceHealth(healthService); int maxThreadCount = arguments.MaxParallel; if (maxThreadCount <= 0) { maxThreadCount = Environment.ProcessorCount - 1; } var taskScheduler = new StaTaskScheduler(maxThreadCount); var removeOverlapsServiceImpl = new RemoveOverlapsGrpcImpl(taskScheduler) { //Health = health }; var advancedReshapeServiceImpl = new AdvancedReshapeGrpcImpl(taskScheduler); var changeAlongServiceImpl = new ChangeAlongGrpcImpl(taskScheduler); //health.SetStatus(removeOverlapsServiceImpl.GetType(), true); ServerCredentials serverCredentials = GrpcServerUtils.GetServerCredentials(arguments.Certificate, arguments.PrivateKeyFile); var oneGb = (int)Math.Pow(1024, 3); IList <ChannelOption> channelOptions = GrpcServerUtils.CreateChannelOptions(oneGb); var server = new Grpc.Core.Server(channelOptions) { Services = { RemoveOverlapsGrpc.BindService(removeOverlapsServiceImpl), ReshapeGrpc.BindService(advancedReshapeServiceImpl), ChangeAlongGrpc.BindService(changeAlongServiceImpl) //Health.BindService(healthService) }, Ports = { new ServerPort(arguments.HostName, arguments.Port, serverCredentials) } }; server.Start(); _msg.InfoFormat("Service is listening on host {0}, port {1}.", arguments.HostName, arguments.Port); return(server); }