Skip to content

Commit 514ae58

Browse files
author
Daniil Fedotov
committed
Start/stop windows service using net utility instead of erlsrv
`erlsrv` doc suggests to use windows system control tools to control services. It prints weird error when error is occured (for example access is denied), so using `net` is prefered.
1 parent 2a01b6c commit 514ae58

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

scripts/rabbitmq-service.bat

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ if not exist "!ERLANG_SERVICE_MANAGER_PATH!\erlsrv.exe" (
7676
)
7777

7878
if "!P1!" == "install" goto INSTALL_SERVICE
79-
for %%i in (start stop disable enable list remove) do if "%%i" == "!P1!" goto MODIFY_SERVICE
79+
for %%i in (start stop) do if "%%i" == "!P1!" goto START_STOP_SERVICE
80+
for %%i in (disable enable list remove) do if "%%i" == "!P1!" goto MODIFY_SERVICE
8081

8182
echo.
8283
echo *********************
@@ -226,16 +227,27 @@ set ERLANG_SERVICE_ARGUMENTS=!ERLANG_SERVICE_ARGUMENTS:"=\"!
226227
if ERRORLEVEL 1 (
227228
EXIT /B 1
228229
)
229-
230230
goto END
231231

232232

233233
:MODIFY_SERVICE
234234

235235
"!ERLANG_SERVICE_MANAGER_PATH!\erlsrv" !P1! !RABBITMQ_SERVICENAME!
236+
if ERRORLEVEL 1 (
237+
EXIT /B 1
238+
)
236239
goto END
237240

238241

242+
:START_STOP_SERVICE
243+
244+
REM start and stop via erlsrv reports no error message. Using net instead
245+
net !P1! !RABBITMQ_SERVICENAME!
246+
if ERRORLEVEL 1 (
247+
EXIT /B 1
248+
)
249+
goto END
250+
239251
:END
240252

241253
EXIT /B 0

0 commit comments

Comments
 (0)