mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 14:37:44 +01:00
Spaces to Tabs
This commit is contained in:
@@ -383,12 +383,12 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
if (!PrecompileHook())
|
||||
{
|
||||
lastCompilerError = "The precompile hook failed";
|
||||
compilerCurrentStatus = TGCompilerStatus.Initialized; //still fairly valid
|
||||
return;
|
||||
}
|
||||
if (!PrecompileHook())
|
||||
{
|
||||
lastCompilerError = "The precompile hook failed";
|
||||
compilerCurrentStatus = TGCompilerStatus.Initialized; //still fairly valid
|
||||
return;
|
||||
}
|
||||
|
||||
using (var DM = new Process()) //will kill the process if the thread is terminated
|
||||
{
|
||||
|
||||
@@ -4,62 +4,62 @@ using System.IO;
|
||||
|
||||
namespace TGServerService
|
||||
{
|
||||
// Some useful functions for triggering pre action events
|
||||
partial class TGStationServer
|
||||
{
|
||||
const string EventFolder = "EventHandlers/";
|
||||
// Some useful functions for triggering pre action events
|
||||
partial class TGStationServer
|
||||
{
|
||||
const string EventFolder = "EventHandlers/";
|
||||
|
||||
string GetPath(string eventName)
|
||||
{
|
||||
return string.Format("{}{}.bat", EventFolder, eventName);
|
||||
}
|
||||
string GetPath(string eventName)
|
||||
{
|
||||
return string.Format("{}{}.bat", EventFolder, eventName);
|
||||
}
|
||||
|
||||
bool EventHandlerExists(string eventName)
|
||||
{
|
||||
return File.Exists(GetPath(eventName));
|
||||
}
|
||||
bool EventHandlerExists(string eventName)
|
||||
{
|
||||
return File.Exists(GetPath(eventName));
|
||||
}
|
||||
|
||||
bool HandleEvent(string eventName)
|
||||
{
|
||||
if (!EventHandlerExists(eventName))
|
||||
{
|
||||
// We don't need a handler, so let's just fail silently.
|
||||
return true;
|
||||
}
|
||||
bool HandleEvent(string eventName)
|
||||
{
|
||||
if (!EventHandlerExists(eventName))
|
||||
{
|
||||
// We don't need a handler, so let's just fail silently.
|
||||
return true;
|
||||
}
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = GetPath(eventName),
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = GetPath(eventName),
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
|
||||
var stdout = process.StandardOutput.ReadToEnd();
|
||||
var stderr = process.StandardError.ReadToEnd();
|
||||
var stdout = process.StandardOutput.ReadToEnd();
|
||||
var stderr = process.StandardError.ReadToEnd();
|
||||
|
||||
TGServerService.WriteInfo(
|
||||
String.Format("Preaction Event ran. Stdout:\n{}\nStderr:\n{}", stdout, stderr),
|
||||
process.ExitCode == 0 ? TGServerService.EventID.PreactionEvent : TGServerService.EventID.PreactionFail
|
||||
);
|
||||
TGServerService.WriteInfo(
|
||||
String.Format("Preaction Event ran. Stdout:\n{}\nStderr:\n{}", stdout, stderr),
|
||||
process.ExitCode == 0 ? TGServerService.EventID.PreactionEvent : TGServerService.EventID.PreactionFail
|
||||
);
|
||||
|
||||
return process.ExitCode == 0 ? true : false;
|
||||
}
|
||||
return process.ExitCode == 0 ? true : false;
|
||||
}
|
||||
|
||||
public bool PrecompileHook()
|
||||
{
|
||||
return HandleEvent("precompile");
|
||||
}
|
||||
public bool PrecompileHook()
|
||||
{
|
||||
return HandleEvent("precompile");
|
||||
}
|
||||
|
||||
public bool PostcompileHook()
|
||||
{
|
||||
return HandleEvent("postcompile");
|
||||
}
|
||||
}
|
||||
public bool PostcompileHook()
|
||||
{
|
||||
return HandleEvent("postcompile");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace TGServerService
|
||||
IRCLogModes = 6500,
|
||||
SubmoduleReclone = 6600,
|
||||
PreactionEvent = 6700,
|
||||
PreactionFail = 6800
|
||||
PreactionFail = 6800
|
||||
}
|
||||
|
||||
static TGServerService ActiveService; //So everyone else can write to our eventlog
|
||||
|
||||
Reference in New Issue
Block a user