mirror of
https://github.com/winsw/winsw.git
synced 2025-12-10 18:37:28 +08:00
ready to push 1.3
git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@6 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa
This commit is contained in:
46
Main.cs
46
Main.cs
@@ -177,8 +177,54 @@ namespace winsw
|
||||
o.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the file copy instructions, so that we can replace files that are always in use while
|
||||
/// the service runs.
|
||||
/// </summary>
|
||||
private void HandleFileCopies()
|
||||
{
|
||||
var file = descriptor.BasePath + ".copies";
|
||||
if (!File.Exists(file))
|
||||
return; // nothing to handle
|
||||
|
||||
try
|
||||
{
|
||||
using (var tr = new StreamReader(file,Encoding.UTF8))
|
||||
{
|
||||
string line;
|
||||
while ((line = tr.ReadLine()) != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
EventLog.WriteEntry("Handling copy: " + line);
|
||||
string[] tokens = line.Split('>');
|
||||
if (tokens.Length > 2)
|
||||
{
|
||||
EventLog.WriteEntry("Too many delimiters in " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
File.Delete(tokens[1]);
|
||||
File.Move(tokens[0], tokens[1]);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
EventLog.WriteEntry("Failed to copy :"+line+" because "+e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnStart(string[] args)
|
||||
{
|
||||
HandleFileCopies();
|
||||
|
||||
EventLog.WriteEntry("Starting "+descriptor.Executable+' '+descriptor.Arguments);
|
||||
string baseName = descriptor.BasePath;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user