public static int Main(string[] args) { CompilerServerLogger.Initialize("SRV"); CompilerServerLogger.Log("Process started"); var keepAliveTimeout = GetKeepAliveTimeout(); // Pipename should be passed as the first and only argument to the server process // and it must have the form "-pipename:name". Otherwise, exit with a non-zero // exit code const string pipeArgPrefix = "-pipename:"; if (args.Length != 1 || args[0].Length <= pipeArgPrefix.Length || !args[0].StartsWith(pipeArgPrefix)) { return(CommonCompiler.Failed); } var pipeName = args[0].Substring(pipeArgPrefix.Length); var serverMutexName = BuildProtocolConstants.GetServerMutexName(pipeName); // VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the // location of the response files. var clientDirectory = AppDomain.CurrentDomain.BaseDirectory; var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory(); var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory); var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName); return(Run(serverMutexName, clientConnectionHost, keepAliveTimeout)); }
public static int Main(string[] args) { CompilerServerLogger.Initialize("SRV"); CompilerServerLogger.Log("Process started"); var keepAliveTimeout = GetKeepAliveTimeout(); // Pipename should be passed as the first and only argument to the server process // and it must have the form "-pipename:name". Otherwise, exit with a non-zero // exit code const string pipeArgPrefix = "-pipename:"; if (args.Length != 1 || args[0].Length <= pipeArgPrefix.Length || !args[0].StartsWith(pipeArgPrefix)) { return CommonCompiler.Failed; } var pipeName = args[0].Substring(pipeArgPrefix.Length); var serverMutexName = $"{pipeName}.server"; // VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the // location of the response files. var clientDirectory = AppDomain.CurrentDomain.BaseDirectory; var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory(); var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory); var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName); return Run(serverMutexName, clientConnectionHost, keepAliveTimeout); }
protected override IClientConnectionHost CreateClientConnectionHost(string pipeName) { // VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the // location of the response files. var clientDirectory = AppDomain.CurrentDomain.BaseDirectory; var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory(); var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory); return new NamedPipeClientConnectionHost(compilerServerHost, pipeName); }
protected override IClientConnectionHost CreateClientConnectionHost(string pipeName) { // VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the // location of the response files. var clientDirectory = AppDomain.CurrentDomain.BaseDirectory; var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory(); var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory); return(new NamedPipeClientConnectionHost(compilerServerHost, pipeName)); }
internal static int RunServer(string pipeName, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(pipeName)) { return CommonCompiler.Failed; } var keepAliveTimeout = GetKeepAliveTimeout(); var serverMutexName = BuildProtocolConstants.GetServerMutexName(pipeName); // VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the // location of the response files. var clientDirectory = AppDomain.CurrentDomain.BaseDirectory; var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory(); var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory); var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName); return Run(serverMutexName, clientConnectionHost, keepAliveTimeout, cancellationToken); }
internal static int RunServer(string pipeName, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(pipeName)) { return(CommonCompiler.Failed); } var keepAliveTimeout = GetKeepAliveTimeout(); var serverMutexName = BuildProtocolConstants.GetServerMutexName(pipeName); // VBCSCompiler is installed in the same directory as csc.exe and vbc.exe which is also the // location of the response files. var clientDirectory = AppDomain.CurrentDomain.BaseDirectory; var sdkDirectory = RuntimeEnvironment.GetRuntimeDirectory(); var compilerServerHost = new DesktopCompilerServerHost(clientDirectory, sdkDirectory); var clientConnectionHost = new NamedPipeClientConnectionHost(compilerServerHost, pipeName); return(Run(serverMutexName, clientConnectionHost, keepAliveTimeout, cancellationToken)); }
private static int Run(TimeSpan? keepAliveTimeout, string compilerExeDirectory, string pipeName) { try { int keepAliveValue; string keepAliveStr = ConfigurationManager.AppSettings["keepalive"]; if (int.TryParse(keepAliveStr, NumberStyles.Integer, CultureInfo.InvariantCulture, out keepAliveValue) && keepAliveValue >= 0) { if (keepAliveValue == 0) { // This is a one time server entry. keepAliveTimeout = null; } else { keepAliveTimeout = TimeSpan.FromSeconds(keepAliveValue); } } else { keepAliveTimeout = ServerDispatcher.DefaultServerKeepAlive; } } catch (ConfigurationErrorsException e) { keepAliveTimeout = ServerDispatcher.DefaultServerKeepAlive; CompilerServerLogger.LogException(e, "Could not read AppSettings"); } CompilerServerLogger.Log("Keep alive timeout is: {0} milliseconds.", keepAliveTimeout?.TotalMilliseconds ?? 0); FatalError.Handler = FailFast.OnFatalException; var compilerServerHost = new DesktopCompilerServerHost(pipeName); var dispatcher = new ServerDispatcher( compilerServerHost, new CompilerRequestHandler(compilerServerHost, compilerExeDirectory), new EmptyDiagnosticListener()); dispatcher.ListenAndDispatchConnections(keepAliveTimeout); return CommonCompiler.Succeeded; }