/// <summary> /// Default constructor /// </summary> /// <param name="options"> /// Options parsed from CLI args to determine IP/host and port to bind /// </param> public PluginServer(PluginCliOptions options) { ExitHandle = new AutoResetEvent(false); _grpcServer = new Server { Services = { CIPlugin.BindService(new GitLabCIPlugin(() => ExitHandle.Set())) }, Ports = { new ServerPort(options.LaunchIp, options.LaunchPort, ServerCredentials.Insecure) } }; }
private static async Task StartServer(PluginCliOptions options) { var pluginServer = new PluginServer(options); pluginServer.Start(); var channel = new Channel(PLUGIN_HOST_IP, PLUGIN_HOST_PORT, ChannelCredentials.Insecure); var pluginHostClient = new CIPluginHost.CIPluginHostClient(channel); var registrationReply = await pluginHostClient.RegisterAsync(new PluginRegistration { PluginName = options.PluginName, PluginPort = options.LaunchPort }); if (registrationReply.RegistrationCode != PluginRegistrationReply.Types.PluginRegistrationCode.Success) { await pluginServer.ShutdownAsync(); } pluginServer.ExitHandle.WaitOne(); await pluginServer.ShutdownAsync(); }