Factor out common pid file creation and removal code.

Log path at which pid file is created or reason for failure to create.
This commit is contained in:
Justin Clark-Casey (justincc)
2012-11-22 05:14:08 +00:00
parent 42e87a6582
commit 8269d2b893
3 changed files with 50 additions and 62 deletions

View File

@@ -69,10 +69,6 @@ namespace OpenSim.Server.Base
//
private bool m_Running = true;
// PID file
//
private string m_pidFile = String.Empty;
// Handle all the automagical stuff
//
public ServicesServerBase(string prompt, string[] args) : base()
@@ -240,8 +236,8 @@ namespace OpenSim.Server.Base
}
}
if (m_pidFile != String.Empty)
File.Delete(m_pidFile);
RemovePIDFile();
return 0;
}
@@ -249,6 +245,7 @@ namespace OpenSim.Server.Base
{
m_Running = false;
m_log.Info("[CONSOLE] Quitting");
}
protected virtual void HandleScript(string module, string[] parms)
@@ -292,21 +289,5 @@ namespace OpenSim.Server.Base
protected virtual void Initialise()
{
}
protected void CreatePIDFile(string path)
{
try
{
string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
FileStream fs = File.Create(path);
Byte[] buf = Encoding.ASCII.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length);
fs.Close();
m_pidFile = path;
}
catch (Exception)
{
}
}
}
}