private bool CheckCompiler() { CheckCompilerBinary(); idleTimer?.Destroy(); if (BinaryPath == null) { return(false); } if (process != null && !process.HasExited) { return(true); } PurgeOldLogs(); Shutdown(); var args = new [] { "/service", "/logPath:" + EscapeArgument(Interface.Oxide.LogDirectory) }; try { process = new Process { StartInfo = { FileName = BinaryPath, Arguments = string.Join(" ", args), CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true }, EnableRaisingEvents = true }; process.Exited += OnProcessExited; process.Start(); } catch (Exception ex) { process?.Dispose(); process = null; Interface.Oxide.LogException("Exception while starting compiler: ", ex); if (ex.GetBaseException() != ex) { Interface.Oxide.LogException("BaseException: ", ex.GetBaseException()); } } if (process == null) { return(false); } client = new ObjectStreamClient <CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream); client.Message += OnMessage; client.Error += OnError; client.Start(); return(true); }
private bool CheckCompiler() { CheckCompilerBinary(); idleTimer?.Destroy(); if (BinaryPath == null) { return(false); } if (process != null && !process.HasExited) { return(true); } PurgeOldLogs(); Shutdown(); var args = new[] { "/service", "/logPath:" + EscapeArgument(Interface.Oxide.LogDirectory) }; try { process = new Process { StartInfo = { FileName = BinaryPath, Arguments = string.Join(" ", args), CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true }, EnableRaisingEvents = true }; //string path; switch (Environment.OSVersion.Platform) { case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.Win32NT: //var currentPath = process.StartInfo.EnvironmentVariables["PATH"] ?? Environment.GetEnvironmentVariable("PATH"); //path = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, "x86")}"; //var newPath = string.IsNullOrEmpty(currentPath) ? path : $"{currentPath}{Path.PathSeparator}{path}"; process.StartInfo.EnvironmentVariables["PATH"] = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, "x86")}"; break; case PlatformID.Unix: case PlatformID.MacOSX: //var currentLdLibraryPath = process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] ?? Environment.GetEnvironmentVariable("LD_LIBRARY_PATH"); //path = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")}"; //var newLdLibraryPath = string.IsNullOrEmpty(currentLdLibraryPath) ? path : $"{currentLdLibraryPath}{Path.PathSeparator}{path}"; process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")}"; break; } process.Exited += OnProcessExited; process.Start(); } catch (Exception ex) { process?.Dispose(); process = null; Interface.Oxide.LogException("Exception while starting compiler: ", ex); // TODO: Expand, warn that it may not be executable? if (ex.GetBaseException() != ex) { Interface.Oxide.LogException("BaseException: ", ex.GetBaseException()); } } if (process == null) { return(false); } client = new ObjectStreamClient <CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream); client.Message += OnMessage; client.Error += OnError; client.Start(); return(true); }
private bool CheckCompiler() { CheckCompilerBinary(); idleTimer?.Destroy(); if (BinaryPath == null) return false; if (process != null && !process.HasExited) return true; PurgeOldLogs(); Shutdown(); var args = new [] {"/service", "/logPath:" + EscapeArgument(Interface.Oxide.LogDirectory)}; try { process = new Process { StartInfo = { FileName = BinaryPath, Arguments = string.Join(" ", args), CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true }, EnableRaisingEvents = true }; string path; switch (Environment.OSVersion.Platform) { case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.Win32NT: var currentPath = process.StartInfo.EnvironmentVariables["PATH"] ?? Environment.GetEnvironmentVariable("PATH"); path = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, "x86")}"; var newPath = string.IsNullOrEmpty(currentPath) ? path : $"{currentPath}{Path.PathSeparator}{path}"; process.StartInfo.EnvironmentVariables["PATH"] = newPath; break; case PlatformID.Unix: case PlatformID.MacOSX: var currentLdLibraryPath = process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] ?? Environment.GetEnvironmentVariable("LD_LIBRARY_PATH"); path = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")}"; var newLdLibraryPath = string.IsNullOrEmpty(currentLdLibraryPath) ? path : $"{currentLdLibraryPath}{Path.PathSeparator}{path}"; process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] = newLdLibraryPath; break; } process.Exited += OnProcessExited; process.Start(); } catch (Exception ex) { process?.Dispose(); process = null; Interface.Oxide.LogException("Exception while starting compiler: ", ex); if (ex.GetBaseException() != ex) Interface.Oxide.LogException("BaseException: ", ex.GetBaseException()); } if (process == null) return false; client = new ObjectStreamClient<CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream); client.Message += OnMessage; client.Error += OnError; client.Start(); return true; }
private bool CheckCompiler() { CheckCompilerBinary(); idleTimer?.Destroy(); if (BinaryPath == null) { return(false); } if (process != null && process.Handle != IntPtr.Zero && !process.HasExited) { return(true); } SetCompilerVersion(); PurgeOldLogs(); Shutdown(); var args = new[] { "/service", "/logPath:" + EscapePath(Interface.Oxide.LogDirectory) }; try { process = new Process { StartInfo = { FileName = BinaryPath, Arguments = string.Join(" ", args), CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true }, EnableRaisingEvents = true }; switch (Environment.OSVersion.Platform) { case PlatformID.Win32S: case PlatformID.Win32Windows: case PlatformID.Win32NT: process.StartInfo.EnvironmentVariables["PATH"] = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, "x86")}"; break; case PlatformID.Unix: case PlatformID.MacOSX: process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")}"; break; } process.Exited += OnProcessExited; process.Start(); } catch (Exception ex) { process?.Dispose(); process = null; Interface.Oxide.LogException($"Exception while starting compiler v{CompilerVersion}: ", ex); if (BinaryPath.Contains("'")) { Interface.Oxide.LogWarning("Server directory path contains an apostrophe, compiler will not work until path is renamed"); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { Interface.Oxide.LogWarning("Compiler may not be set as executable; chmod +x or 0744/0755 required"); } if (ex.GetBaseException() != ex) { Interface.Oxide.LogException("BaseException: ", ex.GetBaseException()); } var win32 = ex as Win32Exception; if (win32 != null) { Interface.Oxide.LogError("Win32 NativeErrorCode: {0} ErrorCode: {1} HelpLink: {2}", win32.NativeErrorCode, win32.ErrorCode, win32.HelpLink); } } if (process == null) { return(false); } client = new ObjectStreamClient <CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream); client.Message += OnMessage; client.Error += OnError; client.Start(); return(true); }
private bool CheckCompiler() { CheckCompilerBinary(); idleTimer?.Destroy(); if (BinaryPath == null) return false; if (process != null && !process.HasExited) return true; PurgeOldLogs(); Shutdown(); var args = new [] {"/service", "/logPath:" + EscapeArgument(Interface.Oxide.LogDirectory)}; try { process = new Process { StartInfo = { FileName = BinaryPath, Arguments = string.Join(" ", args), CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true }, EnableRaisingEvents = true }; process.Exited += OnProcessExited; process.Start(); } catch (Exception ex) { Interface.Oxide.LogException("Exception while starting compiler: ", ex); } if (process == null) return false; client = new ObjectStreamClient<CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream); client.Message += OnMessage; client.Error += OnError; client.Start(); return true; }