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

@@ -61,8 +61,6 @@ namespace OpenSim.Framework.Servers
/// server.
/// </summary>
private Timer m_periodicDiagnosticsTimer = new Timer(60 * 60 * 1000);
protected string m_pidFile = String.Empty;
/// <summary>
/// Random uuid for private data
@@ -293,23 +291,6 @@ namespace OpenSim.Framework.Servers
MainConsole.Instance.OutputFormat("ERROR - Thread with id {0} not found in managed threads", threadId);
}
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)
{
}
}
public string osSecret {
// Secret uuid for the simulator
get { return m_osSecret; }
@@ -327,20 +308,5 @@ namespace OpenSim.Framework.Servers
return StatsManager.SimExtraStats.XReport((DateTime.Now - m_startuptime).ToString() , m_version);
}
}
protected void RemovePIDFile()
{
if (m_pidFile != String.Empty)
{
try
{
File.Delete(m_pidFile);
m_pidFile = String.Empty;
}
catch (Exception)
{
}
}
}
}
}
}