mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 05:56:58 +01:00
Logging Refactor + Event IDs (#57)
* Logging Refactor + Event IDs * x1000 * Fixes * Some misses
This commit is contained in:
@@ -175,7 +175,7 @@ namespace TGServerService
|
||||
{
|
||||
SendMessage("BYOND: Update download failed. Does the specified version exist?");
|
||||
lastError = String.Format("Download of BYOND version {0}.{1} failed! Does it exist?", vi.major, vi.minor);
|
||||
TGServerService.WriteLog(String.Format("Failed to update BYOND to version {0}.{1}!", vi.major, vi.minor), EventLogEntryType.Warning);
|
||||
TGServerService.WriteWarning(String.Format("Failed to update BYOND to version {0}.{1}!", vi.major, vi.minor), TGServerService.EventID.BYONDUpdateFail);
|
||||
lock (ByondLock)
|
||||
{
|
||||
updateStat = TGByondStatus.Idle;
|
||||
@@ -217,7 +217,7 @@ namespace TGServerService
|
||||
RequestRestart();
|
||||
lastError = "Update staged. Awaiting server restart...";
|
||||
SendMessage(String.Format("BYOND: Staging complete. Awaiting server restart...", vi.major, vi.minor));
|
||||
TGServerService.WriteLog(String.Format("BYOND update {0}.{1} staged", vi.major, vi.minor));
|
||||
TGServerService.WriteInfo(String.Format("BYOND update {0}.{1} staged", vi.major, vi.minor), TGServerService.EventID.BYONDUpdateStaged);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace TGServerService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteLog("Revision staging errror: " + e.ToString(), EventLogEntryType.Error);
|
||||
TGServerService.WriteError("Revision staging errror: " + e.ToString(), TGServerService.EventID.BYONDUpdateFail);
|
||||
lock (ByondLock)
|
||||
{
|
||||
updateStat = TGByondStatus.Idle;
|
||||
@@ -274,14 +274,14 @@ namespace TGServerService
|
||||
Program.DeleteDirectory(StagingDirectory);
|
||||
lastError = null;
|
||||
SendMessage("BYOND: Update completed!");
|
||||
TGServerService.WriteLog(String.Format("BYOND update {0} completed!", GetVersion(TGByondVersion.Installed)));
|
||||
TGServerService.WriteInfo(String.Format("BYOND update {0} completed!", GetVersion(TGByondVersion.Installed)), TGServerService.EventID.BYONDUpdateComplete);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
lastError = e.ToString();
|
||||
SendMessage("BYOND: Update failed!");
|
||||
TGServerService.WriteLog("BYOND update failed!");
|
||||
TGServerService.WriteError("BYOND update failed!", TGServerService.EventID.BYONDUpdateFail);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -67,13 +67,13 @@ namespace TGServerService
|
||||
ChatProvider = new TGIRCChatProvider(info);
|
||||
break;
|
||||
default:
|
||||
TGServerService.WriteLog(String.Format("Invalid chat provider: {0}", info.Provider), EventLogEntryType.Error);
|
||||
TGServerService.WriteError(String.Format("Invalid chat provider: {0}", info.Provider), TGServerService.EventID.InvalidChatProvider);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteLog(String.Format("Failed to start chat provider {0}! Error: {1}", info.Provider, e.ToString()), EventLogEntryType.Error);
|
||||
TGServerService.WriteError(String.Format("Failed to start chat provider {0}! Error: {1}", info.Provider, e.ToString()), TGServerService.EventID.ChatProviderStartFail);
|
||||
return;
|
||||
}
|
||||
ChatProvider.OnChatMessage += ChatProvider_OnChatMessage;
|
||||
@@ -81,7 +81,7 @@ namespace TGServerService
|
||||
{
|
||||
var res = ChatProvider.Connect();
|
||||
if (res != null)
|
||||
TGServerService.WriteLog(String.Format("Unable to connect to chat! Provider {0}, Error: {1}", ChatProvider.GetType().ToString(), res));
|
||||
TGServerService.WriteWarning(String.Format("Unable to connect to chat! Provider {0}, Error: {1}", ChatProvider.GetType().ToString(), res), TGServerService.EventID.ChatConnectFail);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace TGServerService
|
||||
//Do stuff with words that were spoken to us
|
||||
string ChatCommand(string command, string speaker, string channel, IList<string> parameters)
|
||||
{
|
||||
TGServerService.WriteLog(String.Format("Chat Command from {0}: {1} {2}", speaker, command, String.Join(" ", parameters)));
|
||||
TGServerService.WriteInfo(String.Format("Chat Command from {0}: {1} {2}", speaker, command, String.Join(" ", parameters)), TGServerService.EventID.ChatCommand);
|
||||
switch (command)
|
||||
{
|
||||
case "check":
|
||||
@@ -256,7 +256,7 @@ namespace TGServerService
|
||||
case TGChatProvider.IRC:
|
||||
return new TGIRCSetupInfo();
|
||||
default:
|
||||
TGServerService.WriteLog("Invalid chat provider: " + Config.ChatProvider.ToString());
|
||||
TGServerService.WriteError("Invalid chat provider: " + Config.ChatProvider.ToString(), TGServerService.EventID.InvalidChatProvider);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -346,6 +346,7 @@ namespace TGServerService
|
||||
{
|
||||
var errorMsg = String.Format("Could not find {0}!", dmeName);
|
||||
SendMessage("DM: " + errorMsg);
|
||||
TGServerService.WriteError(errorMsg, TGServerService.EventID.DMCompileCrash);
|
||||
lock (CompilerLock)
|
||||
{
|
||||
lastCompilerError = errorMsg;
|
||||
@@ -438,7 +439,9 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
}
|
||||
SendMessage(String.Format("DM: Compile complete!{0}", DaemonStatus() == TGDreamDaemonStatus.Offline ? "" : " Server will update next round."));
|
||||
var msg = String.Format("Compile complete!{0}", DaemonStatus() == TGDreamDaemonStatus.Offline ? "" : " Server will update next round.");
|
||||
SendMessage("DM: " + msg);
|
||||
TGServerService.WriteInfo(msg, TGServerService.EventID.DMCompileSuccess);
|
||||
lock (CompilerLock)
|
||||
{
|
||||
lastCompilerError = null;
|
||||
@@ -448,7 +451,7 @@ namespace TGServerService
|
||||
else
|
||||
{
|
||||
SendMessage("DM: Compile failed!"); //Also happens for warnings
|
||||
TGServerService.WriteLog("Compile error: " + OutputList.ToString(), EventLogEntryType.Warning);
|
||||
TGServerService.WriteWarning("Compile error: " + OutputList.ToString(), TGServerService.EventID.DMCompileError);
|
||||
lock (CompilerLock)
|
||||
{
|
||||
lastCompilerError = "DM compile failure";
|
||||
@@ -465,7 +468,7 @@ namespace TGServerService
|
||||
catch (Exception e)
|
||||
{
|
||||
SendMessage("DM: Compiler thread crashed!");
|
||||
TGServerService.WriteLog("Compile manager errror: " + e.ToString(), EventLogEntryType.Error);
|
||||
TGServerService.WriteError("Compile manager errror: " + e.ToString(), TGServerService.EventID.DMCompileCrash);
|
||||
lock (CompilerLock)
|
||||
{
|
||||
lastCompilerError = e.ToString();
|
||||
@@ -482,6 +485,7 @@ namespace TGServerService
|
||||
compilerCurrentStatus = TGCompilerStatus.Initialized;
|
||||
compilationCancellationRequestation = false;
|
||||
SendMessage("Compile cancelled!");
|
||||
TGServerService.WriteInfo("Compilation cancelled", TGServerService.EventID.DMCompileCancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,9 +291,10 @@ namespace TGServerService
|
||||
//public api
|
||||
public string MoveServer(string new_location)
|
||||
{
|
||||
var Config = Properties.Settings.Default;
|
||||
try
|
||||
{
|
||||
var di1 = new DirectoryInfo(Environment.CurrentDirectory);
|
||||
var di1 = new DirectoryInfo(Config.ServerDirectory);
|
||||
var di2 = new DirectoryInfo(new_location);
|
||||
|
||||
var copy = di1.Root.FullName != di2.Root.FullName;
|
||||
@@ -335,7 +336,6 @@ namespace TGServerService
|
||||
{
|
||||
if (currentStatus != TGDreamDaemonStatus.Offline)
|
||||
return "Watchdog running!";
|
||||
var Config = Properties.Settings.Default;
|
||||
lock (configLock)
|
||||
{
|
||||
CleanGameFolder();
|
||||
@@ -350,9 +350,10 @@ namespace TGServerService
|
||||
{
|
||||
Program.DeleteDirectory(Config.ServerDirectory);
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
error = "The move was successful, but the path " + Config.ServerDirectory + " was unable to be deleted fully!";
|
||||
TGServerService.WriteWarning(String.Format("Server move from {0} to {1} partial success: {2}", Config.ServerDirectory, new_location, e.ToString()), TGServerService.EventID.ServerMovePartial);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -363,14 +364,14 @@ namespace TGServerService
|
||||
Directory.Move(Config.ServerDirectory, new_location);
|
||||
Environment.CurrentDirectory = new_location;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch
|
||||
{
|
||||
Environment.CurrentDirectory = Config.ServerDirectory;
|
||||
return e.ToString();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
TGServerService.WriteInfo(String.Format("Server moved from {0} to {1}", Config.ServerDirectory, new_location), TGServerService.EventID.ServerMoveComplete);
|
||||
Config.ServerDirectory = new_location;
|
||||
TGServerService.WriteLog("Server moved to: " + new_location);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -396,6 +397,7 @@ namespace TGServerService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError(String.Format("Server move from {0} to {1} failed: {2}", Config.ServerDirectory, new_location, e.ToString()), TGServerService.EventID.ServerMoveFailed);
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace TGServerService
|
||||
}
|
||||
foreach (var I in tasks)
|
||||
I.Wait();
|
||||
TGServerService.WriteLog(String.Format("Discord Send ({0}): {1}", adminOnly ? "Broadcast" : "Admin", msg));
|
||||
TGServerService.WriteInfo(String.Format("Discord Send{0}: {1}", adminOnly ? " (ADMIN)" : "", msg), adminOnly ? TGServerService.EventID.ChatAdminBroadcast : TGServerService.EventID.ChatBroadcast);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ namespace TGServerService
|
||||
foreach (var J in I.TextChannels)
|
||||
if (J.Id == channel)
|
||||
J.SendMessage(message).Wait();
|
||||
TGServerService.WriteLog(String.Format("Discord Send ({0}): {1}", channel, message));
|
||||
TGServerService.WriteInfo(String.Format("Discord Send ({0}): {1}", channelname, message), TGServerService.EventID.ChatSend);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ namespace TGServerService
|
||||
client.Disconnect().Wait();
|
||||
}
|
||||
catch (Exception e) {
|
||||
TGServerService.WriteLog("Discord failed DnD: " + e.ToString());
|
||||
TGServerService.WriteError("Discord failed DnD: " + e.ToString(), TGServerService.EventID.ChatDisconnectFail);
|
||||
}
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace TGServerService
|
||||
Proc = Process.GetProcessById(Properties.Settings.Default.ReattachPID);
|
||||
if (Proc == null)
|
||||
throw new Exception("GetProcessById returned null!");
|
||||
TGServerService.WriteLog("Reattached to running DD process!");
|
||||
TGServerService.WriteInfo("Reattached to running DD process!", TGServerService.EventID.DDReattachSuccess);
|
||||
SendMessage("DD: Update complete. Watchdog reactivated...");
|
||||
|
||||
//start wd
|
||||
@@ -59,7 +59,7 @@ namespace TGServerService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteLog(String.Format("Failed to reattach to DreamDaemon! PID: {0}. Exception: {1}", Properties.Settings.Default.ReattachPID, e.ToString()), EventLogEntryType.Error);
|
||||
TGServerService.WriteError(String.Format("Failed to reattach to DreamDaemon! PID: {0}. Exception: {1}", Properties.Settings.Default.ReattachPID, e.ToString()), TGServerService.EventID.DDReattachFail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -205,9 +205,15 @@ namespace TGServerService
|
||||
lock (restartLock)
|
||||
{
|
||||
if (!RestartInProgress)
|
||||
{
|
||||
SendMessage("DD: Server started, watchdog active...");
|
||||
TGServerService.WriteInfo("Watchdog started", TGServerService.EventID.DDWatchdogStarted);
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartInProgress = false;
|
||||
TGServerService.WriteInfo("Watchdog started", TGServerService.EventID.DDWatchdogRestarted);
|
||||
}
|
||||
}
|
||||
var retries = 0;
|
||||
while (true)
|
||||
@@ -242,7 +248,9 @@ namespace TGServerService
|
||||
else
|
||||
{
|
||||
retries = 0;
|
||||
SendMessage("DD: DreamDaemon crashed or exited! Rebooting...");
|
||||
var msg = "DD: DreamDaemon crashed! Rebooting...";
|
||||
SendMessage(msg);
|
||||
TGServerService.WriteWarning(msg, TGServerService.EventID.DDWatchdogRebootingServer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +281,7 @@ namespace TGServerService
|
||||
catch (Exception e)
|
||||
{
|
||||
SendMessage("DD: Watchdog thread crashed!");
|
||||
TGServerService.WriteLog("Watch dog thread crashed! Exception: " + e.ToString(), EventLogEntryType.Error);
|
||||
TGServerService.WriteError("Watch dog thread crashed: " + e.ToString(), TGServerService.EventID.DDWatchdogCrash);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -283,7 +291,12 @@ namespace TGServerService
|
||||
currentPort = 0;
|
||||
AwaitingShutdown = ShutdownRequestPhase.None;
|
||||
if (!RestartInProgress)
|
||||
{
|
||||
SendMessage("DD: Server stopped, watchdog exiting...");
|
||||
TGServerService.WriteInfo("Watch dog exited", TGServerService.EventID.DDWatchdogExit);
|
||||
}
|
||||
else
|
||||
TGServerService.WriteInfo("Watch dog restarting...", TGServerService.EventID.DDWatchdogRestart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace TGServerService
|
||||
channel = channel.Replace(PrivateMessageMarker, "");
|
||||
irc.SendMessage(SendType.Message, channel, message);
|
||||
}
|
||||
TGServerService.WriteLog(String.Format("IRC Send ({0}): {1}", channel, message));
|
||||
TGServerService.WriteInfo(String.Format("IRC Send ({0}): {1}", channel, message), TGServerService.EventID.ChatSend);
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -196,8 +196,10 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError("IRC failed QnD: " + e.ToString(), TGServerService.EventID.ChatDisconnectFail);
|
||||
}
|
||||
}
|
||||
//public api
|
||||
public bool Connected()
|
||||
@@ -223,7 +225,7 @@ namespace TGServerService
|
||||
foreach (var I in Config.ChatChannels)
|
||||
irc.SendMessage(SendType.Message, I, message);
|
||||
}
|
||||
TGServerService.WriteLog(String.Format("IRC Send{0}: {1}", adminOnly ? " (ADMIN)" : "", message));
|
||||
TGServerService.WriteInfo(String.Format("IRC Send{0}: {1}", adminOnly ? " (ADMIN)" : "", message), adminOnly ? TGServerService.EventID.ChatAdminBroadcast : TGServerService.EventID.ChatBroadcast);
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace TGServerService
|
||||
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]
|
||||
partial class TGStationServer : IDisposable, ITGSService, ITGServerUpdater
|
||||
{
|
||||
|
||||
//call partial constructors/destructors from here
|
||||
//called when the service is started
|
||||
public TGStationServer()
|
||||
@@ -86,7 +87,7 @@ namespace TGServerService
|
||||
//public api
|
||||
public void StopForUpdate()
|
||||
{
|
||||
TGServerService.WriteLog("Stopping for update!");
|
||||
TGServerService.WriteInfo("Stopping for update!", TGServerService.EventID.UpdateRequest);
|
||||
Properties.Settings.Default.ReattachToDD = true;
|
||||
TGServerService.LocalStop();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace TGServerService
|
||||
SendMessage("RELAY: " + String.Join(" ", splits), true);
|
||||
break;
|
||||
case SRWorldReboot:
|
||||
TGServerService.WriteLog("World Rebooted", EventLogEntryType.Information);
|
||||
TGServerService.WriteInfo("World Rebooted", TGServerService.EventID.WorldReboot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -130,12 +130,12 @@ namespace TGServerService
|
||||
topicSender.Shutdown(SocketShutdown.Both);
|
||||
}
|
||||
|
||||
TGServerService.WriteLog("Topic: \"" + topicdata + "\" Returned: " + returnedString);
|
||||
TGServerService.WriteInfo("Topic: \"" + topicdata + "\" Returned: " + returnedString, TGServerService.EventID.TopicSent);
|
||||
return returnedString;
|
||||
}
|
||||
catch
|
||||
{
|
||||
TGServerService.WriteLog("Failed to send topic: " + topicdata, EventLogEntryType.Error);
|
||||
TGServerService.WriteWarning("Failed to send topic: " + topicdata, TGServerService.EventID.TopicFailed);
|
||||
return "Topic delivery failed!";
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace TGServerService
|
||||
serviceCommsKey += tmp;
|
||||
} while (serviceCommsKey.Length < CommsKeyLen);
|
||||
serviceCommsKey = serviceCommsKey.Substring(0, CommsKeyLen);
|
||||
TGServerService.WriteLog("Service Comms Key set to: " + serviceCommsKey);
|
||||
TGServerService.WriteInfo("Service Comms Key set to: " + serviceCommsKey, TGServerService.EventID.CommsKeySet);
|
||||
}
|
||||
|
||||
//Start listening for nudges on the configured port
|
||||
@@ -193,7 +193,7 @@ namespace TGServerService
|
||||
var np = InteropPort(out string error);
|
||||
if (error != null)
|
||||
{
|
||||
TGServerService.WriteLog("Unable to start nudge handler! Error: " + error, EventLogEntryType.Warning);
|
||||
TGServerService.WriteError("Unable to start nudge handler: " + error, TGServerService.EventID.NudgeStartFail);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace TGServerService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteLog("Nudge handler thread crashed: " + e.ToString(), EventLogEntryType.Error);
|
||||
TGServerService.WriteError("Nudge handler thread crashed: " + e.ToString(), TGServerService.EventID.NudgeCrash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +108,11 @@ namespace TGServerService
|
||||
void Clone(object twostrings)
|
||||
{
|
||||
//busy flag set by caller
|
||||
var ts = (TwoStrings)twostrings;
|
||||
var RepoURL = ts.a;
|
||||
var BranchName = ts.b;
|
||||
try
|
||||
{
|
||||
var ts = (TwoStrings)twostrings;
|
||||
var RepoURL = ts.a;
|
||||
var BranchName = ts.b;
|
||||
SendMessage(String.Format("REPO: {2} started: Cloning {0} branch of {1} ...", BranchName, RepoURL, Repository.IsValid(RepoPath) ? "Full reset" : "Setup"));
|
||||
try
|
||||
{
|
||||
@@ -162,6 +162,7 @@ namespace TGServerService
|
||||
Program.CopyDirectory(RepoData, StaticDataDir, null, true);
|
||||
File.Copy(RepoPath + LibMySQLFile, StaticDirs + LibMySQLFile, true);
|
||||
SendMessage("REPO: Clone complete!");
|
||||
TGServerService.WriteInfo("Repository {0}:{1} successfully cloned", TGServerService.EventID.RepoClone);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -172,7 +173,7 @@ namespace TGServerService
|
||||
|
||||
{
|
||||
SendMessage("REPO: Setup failed!");
|
||||
TGServerService.WriteLog("Clone error: " + e.ToString(), EventLogEntryType.Error);
|
||||
TGServerService.WriteWarning(String.Format("Failed to clone {2}:{0}: {1}", BranchName, e.ToString(), RepoURL), TGServerService.EventID.RepoCloneFail);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -307,12 +308,14 @@ namespace TGServerService
|
||||
Commands.Checkout(Repo, sha, Opts);
|
||||
var res = ResetNoLock(null);
|
||||
SendMessage("REPO: Checkout complete!");
|
||||
TGServerService.WriteInfo("Repo checked out " + sha, TGServerService.EventID.RepoCheckout);
|
||||
return res;
|
||||
}
|
||||
catch (Exception E)
|
||||
catch (Exception e)
|
||||
{
|
||||
SendMessage("REPO: Checkout failed!");
|
||||
return E.ToString();
|
||||
TGServerService.WriteWarning(String.Format("Repo checkout of {0} failed: {1}", sha, e.ToString()), TGServerService.EventID.RepoCheckoutFail);
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,17 +370,22 @@ namespace TGServerService
|
||||
if (reset)
|
||||
{
|
||||
var error = ResetNoLock(Repo.Head.TrackedBranch);
|
||||
if (error == null)
|
||||
DeletePRList();
|
||||
else
|
||||
SendMessage("REPO: Update failed!");
|
||||
if (error != null)
|
||||
throw new Exception(error);
|
||||
DeletePRList();
|
||||
TGServerService.WriteInfo("Repo hard updated to " + originBranch.Tip.Sha, TGServerService.EventID.RepoHardUpdate);
|
||||
return error;
|
||||
}
|
||||
return MergeBranch(originBranch.FriendlyName);
|
||||
var res = MergeBranch(originBranch.FriendlyName);
|
||||
if (res != null)
|
||||
throw new Exception(res);
|
||||
TGServerService.WriteInfo("Repo merge updated to " + originBranch.Tip.Sha, TGServerService.EventID.RepoMergeUpdate);
|
||||
return null;
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
SendMessage("REPO: Update failed!");
|
||||
TGServerService.WriteWarning(String.Format("Repo{0} update failed", reset ? " hard" : ""), reset ? TGServerService.EventID.RepoHardUpdateFail : TGServerService.EventID.RepoMergeUpdateFail);
|
||||
return E.ToString();
|
||||
}
|
||||
}
|
||||
@@ -404,14 +412,15 @@ namespace TGServerService
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
TGServerService.WriteLog("Repo backup created at tag: " + tagName + " commit: " + HEAD);
|
||||
TGServerService.WriteInfo("Repo backup created at tag: " + tagName + " commit: " + HEAD, TGServerService.EventID.RepoBackupTag);
|
||||
return null;
|
||||
}
|
||||
return "Tag creation failed!";
|
||||
throw new Exception("Tag creation failed!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteWarning(String.Format("Failed backup tag creation at commit {0}!", Repo.Head.Tip.Sha), TGServerService.EventID.RepoBackupTagFail);
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
@@ -447,7 +456,11 @@ namespace TGServerService
|
||||
{
|
||||
var res = LoadRepo() ?? ResetNoLock(trackedBranch ? (Repo.Head.TrackedBranch ?? Repo.Head) : Repo.Head);
|
||||
if (trackedBranch && res == null)
|
||||
{
|
||||
DeletePRList();
|
||||
TGServerService.WriteInfo(String.Format("Repo branch reset{0}", trackedBranch ? " to tracked branch" : ""), trackedBranch ? TGServerService.EventID.RepoResetTracked : TGServerService.EventID.RepoReset);
|
||||
}
|
||||
TGServerService.WriteWarning(String.Format("Failed to reset{0}: {1}", trackedBranch ? " to tracked branch" : "", res), trackedBranch ? TGServerService.EventID.RepoResetTrackedFail : TGServerService.EventID.RepoResetFail);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -463,7 +476,14 @@ namespace TGServerService
|
||||
void DeletePRList()
|
||||
{
|
||||
if (File.Exists(PRJobFile))
|
||||
File.Delete(PRJobFile);
|
||||
try
|
||||
{
|
||||
File.Delete(PRJobFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError("Failed to delete PR list: " + e.ToString(), TGServerService.EventID.RepoPRListError);
|
||||
}
|
||||
}
|
||||
|
||||
//json_decode(file2text())
|
||||
@@ -533,6 +553,7 @@ namespace TGServerService
|
||||
|
||||
if (Result == null)
|
||||
{
|
||||
TGServerService.WriteInfo(String.Format("Merged pull request #{0}", PRNumber), TGServerService.EventID.RepoPRMerge);
|
||||
try
|
||||
{
|
||||
var CurrentPRs = GetCurrentPRList();
|
||||
@@ -565,6 +586,7 @@ namespace TGServerService
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
TGServerService.WriteError("Failed to update PR list", TGServerService.EventID.RepoPRListError);
|
||||
return "PR Merged, JSON update failed: " + e.ToString();
|
||||
}
|
||||
}
|
||||
@@ -573,6 +595,7 @@ namespace TGServerService
|
||||
catch (Exception E)
|
||||
{
|
||||
SendMessage("REPO: PR merge failed!");
|
||||
TGServerService.WriteWarning(String.Format("Failed to merge pull request #{0}: {1}", PRNumber, E.ToString()), TGServerService.EventID.RepoPRMergeFail);
|
||||
return E.ToString();
|
||||
}
|
||||
}
|
||||
@@ -663,12 +686,13 @@ namespace TGServerService
|
||||
var authorandcommitter = MakeSig();
|
||||
|
||||
// Commit to the repository
|
||||
Repo.Commit(CommitMessage, authorandcommitter, authorandcommitter);
|
||||
TGServerService.WriteInfo(String.Format("Commit {0} created from changelogs", Repo.Commit(CommitMessage, authorandcommitter, authorandcommitter)), TGServerService.EventID.RepoCommit);
|
||||
DeletePRList();
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError("Repo commit failed: " + e.ToString(), TGServerService.EventID.RepoCommitFail);
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
@@ -693,10 +717,12 @@ namespace TGServerService
|
||||
CredentialsProvider = GenerateGitCredentials,
|
||||
};
|
||||
Repo.Network.Push(Repo.Network.Remotes[SSHPushRemote], Repo.Head.CanonicalName, options);
|
||||
TGServerService.WriteError("Repo pushed up to commit: " + Repo.Head.Tip.Sha, TGServerService.EventID.RepoPush);
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError("Repo push failed: " + e.ToString(), TGServerService.EventID.RepoPushFail);
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
@@ -831,11 +857,13 @@ namespace TGServerService
|
||||
return GenerateChangelogImpl(out error, true);
|
||||
}
|
||||
error = null;
|
||||
TGServerService.WriteWarning("Changelog generated" + error, TGServerService.EventID.RepoChangelog);
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = e.ToString();
|
||||
TGServerService.WriteWarning("Changelog generation failed: " + error, TGServerService.EventID.RepoChangelogFail);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,84 @@ using TGServiceInterface;
|
||||
namespace TGServerService
|
||||
{
|
||||
public partial class TGServerService : ServiceBase
|
||||
{
|
||||
{
|
||||
//only deprecate events, do not reuse them
|
||||
public enum EventID
|
||||
{
|
||||
ChatCommand = 1000,
|
||||
ChatConnectFail = 2000,
|
||||
ChatProviderStartFail = 3000,
|
||||
InvalidChatProvider = 4000,
|
||||
UpdateRequest = 5000,
|
||||
BYONDUpdateFail = 6000,
|
||||
BYONDUpdateStaged = 7000,
|
||||
BYONDUpdateComplete = 8000,
|
||||
ServerMoveFailed = 9000,
|
||||
ServerMovePartial = 10000,
|
||||
ServerMoveComplete = 11000,
|
||||
DMCompileCrash = 12000,
|
||||
DMInitializeCrash = 13000,
|
||||
DMCompileError = 14000,
|
||||
DMCompileSuccess = 15000,
|
||||
DMCompileCancel = 16000,
|
||||
DDReattachFail = 17000,
|
||||
DDReattachSuccess = 18000,
|
||||
DDWatchdogCrash = 19000,
|
||||
DDWatchdogExit = 20000,
|
||||
DDWatchdogRebootedServer = 21000,
|
||||
DDWatchdogRebootingServer = 22000,
|
||||
DDWatchdogRestart = 23000,
|
||||
DDWatchdogRestarted = 24000,
|
||||
DDWatchdogStarted = 25000,
|
||||
ChatSend = 26000,
|
||||
ChatBroadcast = 27000,
|
||||
ChatAdminBroadcast = 28000,
|
||||
ChatDisconnectFail = 29000,
|
||||
TopicSent = 300000,
|
||||
TopicFailed = 31000,
|
||||
CommsKeySet = 32000,
|
||||
NudgeStartFail = 33000,
|
||||
NudgeCrash = 34000,
|
||||
RepoClone = 35000,
|
||||
RepoCloneFail = 36000,
|
||||
RepoCheckout = 37000,
|
||||
RepoCheckoutFail = 38000,
|
||||
RepoHardUpdate = 39000,
|
||||
RepoHardUpdateFail = 40000,
|
||||
RepoMergeUpdate = 41000,
|
||||
RepoMergeUpdateFail = 42000,
|
||||
RepoBackupTag = 43000,
|
||||
RepoBackupTagFail = 44000,
|
||||
RepoResetTracked = 45000,
|
||||
RepoResetTrackedFail = 46000,
|
||||
RepoReset = 47000,
|
||||
RepoResetFail = 48000,
|
||||
RepoPRListError = 49000,
|
||||
RepoPRMerge = 50000,
|
||||
RepoPRMergeFail = 51000,
|
||||
RepoCommit = 52000,
|
||||
RepoCommitFail = 53000,
|
||||
RepoPush = 54000,
|
||||
RepoPushFail = 55000,
|
||||
RepoChangelog = 56000,
|
||||
RepoChangelogFail = 57000,
|
||||
ServiceShutdownFail = 61000,
|
||||
WorldReboot = 62000,
|
||||
}
|
||||
|
||||
static TGServerService ActiveService; //So everyone else can write to our eventlog
|
||||
|
||||
public static void WriteLog(string message, EventLogEntryType type = EventLogEntryType.Information)
|
||||
public static void WriteInfo(string message, EventID id)
|
||||
{
|
||||
ActiveService.EventLog.WriteEntry(message, type);
|
||||
ActiveService.EventLog.WriteEntry(message, EventLogEntryType.Information, (int)id);
|
||||
}
|
||||
public static void WriteError(string message, EventID id)
|
||||
{
|
||||
ActiveService.EventLog.WriteEntry(message, EventLogEntryType.Error, (int)id);
|
||||
}
|
||||
public static void WriteWarning(string message, EventID id)
|
||||
{
|
||||
ActiveService.EventLog.WriteEntry(message, EventLogEntryType.Warning, (int)id);
|
||||
}
|
||||
|
||||
public static void LocalStop()
|
||||
@@ -84,7 +156,7 @@ namespace TGServerService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteLog(e.ToString(), EventLogEntryType.Error);
|
||||
WriteError(e.ToString(), EventID.ServiceShutdownFail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user