Browse Source

restart service revisited

git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@22 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa
jjasper4 17 years ago
parent
commit
cb3cff2dbe
1 changed files with 13 additions and 3 deletions
  1. 13 3
      Main.cs

+ 13 - 3
Main.cs

@@ -474,7 +474,8 @@ namespace winsw
                 }
 
                 StartProcess(stopProcess, stoparguments, executable);
-                stopProcess.WaitForExit();
+//                stopProcess.WaitForExit();
+                process.WaitForExit();
             }
         }
 
@@ -611,9 +612,18 @@ namespace winsw
                 }
                 if (args[0] == "restart")
                 {
-                    if (s == null) ThrowNoSuchService();
+                    if (s == null) 
+                        ThrowNoSuchService();
+
                     if(s.Started)
-                        s.StopService();
+                        s.StopService();
+
+                    while (s.Started)
+                    {
+                        Thread.Sleep(1000);
+                        s = svc.Select(d.Id);
+                    }
+
                     s.StartService();
                 }
                 if (args[0] == "status")