浏览代码

Merge pull request #385 from NextTurn/start

Treat ERROR_SERVICE_ALREADY_RUNNING as success for start command
Oleg Nenashev 5 年之前
父节点
当前提交
7bbe98e326
共有 1 个文件被更改,包括 16 次插入1 次删除
  1. 16 1
      src/Core/ServiceWrapper/Main.cs

+ 16 - 1
src/Core/ServiceWrapper/Main.cs

@@ -718,7 +718,22 @@ namespace winsw
                 if (s is null)
                     ThrowNoSuchService();
 
-                s.StartService();
+                try
+                {
+                    s.StartService();
+                }
+                catch (WmiException e)
+                {
+                    if (e.ErrorCode == ReturnValue.ServiceAlreadyRunning)
+                    {
+                        Log.Info($"The service with ID '{descriptor.Id}' has already been started");
+                    }
+                    else
+                    {
+                        throw;
+                    }
+                }
+
                 return;
             }