Files
tgstation-server/TGServerService/InterfaceBase.cs
T
Jordan BrownandGitHub 4f8a848388 Installer wrapper (#74) [TGSDeploy]
* Add a version command

* Remove service update from commandline

* Ayy lmao

* Fix

* Final touches

* Last thing

* Can't break backwards compat I suppose

* Version bump to 3.0.85.0

* Final cleanup

* This time I swear

* VERY LAST FUCKING THING

* CANT STOP FUCKING UP THE UI

* AHHHH!!!!!

* Do not become like me kids
2017-06-23 11:56:19 -04:00

141 lines
3.3 KiB
C#

using System;
using System.ServiceModel;
using TGServiceInterface;
namespace TGServerService
{
//I know the fact that this is one massive partial class is gonna trigger everyone
//There really was no other succinct way to do it
//this line basically says make one instance of the service, use it multithreaded for requests, and never delete it
[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()
{
InitChat();
InitByond();
InitCompiler();
InitDreamDaemon();
}
//called when the service is stopped
void RunDisposals()
{
DisposeDreamDaemon();
DisposeCompiler();
DisposeByond();
DisposeRepo();
DisposeChat();
}
public string Version()
{
return TGServerService.Version;
}
//one stop update
public string UpdateServer(TGRepoUpdateMethod updateType, bool push_changelog_if_enabled, ushort testmerge_pr)
{
string res;
switch (updateType)
{
case TGRepoUpdateMethod.Hard:
case TGRepoUpdateMethod.Merge:
res = Update(updateType == TGRepoUpdateMethod.Hard);
if (res != null && res != RepoErrorUpToDate)
return res;
break;
case TGRepoUpdateMethod.Reset:
res = Reset(true);
if (res != null)
return res;
break;
case TGRepoUpdateMethod.None:
break;
}
if (testmerge_pr != 0)
{
res = MergePullRequestImpl(testmerge_pr, true);
if (res != null && res != RepoErrorUpToDate)
return res;
}
GenerateChangelog(out res);
if (res != null)
return res;
if (push_changelog_if_enabled && SSHAuth())
{
res = Commit();
if (res != null)
return res;
res = Push();
if (res != null)
return res;
}
if (!Compile(true))
return "Compilation could not be started!";
return null;
}
//public api
public void VerifyConnection() { }
//public api
public void StopForUpdate()
{
PrepareForUpdate();
}
//public api
public void PrepareForUpdate()
{
Properties.Settings.Default.ReattachToDD = true;
}
//mostly generated code with a call to RunDisposals()
//you don't need to open this
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
RunDisposals();
// TODO: dispose managed state (managed objects).
}
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
disposedValue = true;
}
}
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
// ~TGStationServer() {
// // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
// Dispose(false);
// }
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
// TODO: uncomment the following line if the finalizer is overridden above.
// GC.SuppressFinalize(this);
}
#endregion
}
}