summaryrefslogtreecommitdiff
path: root/priv/templates/simplenode.windows.runner.cmd
blob: b5a3a5f42429cf254c3b47612c49bc95ab28f948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@setlocal

@set node_name={{nodeid}}

@rem Get the abolute path to the parent directory,
@rem which is assumed to be the node root.
@for /F "delims=" %%I in ("%~dp0..") do @set node_root=%%~fI

@set releases_dir=%node_root%\releases

@rem Parse ERTS version and release version from start_erl.data
@for /F "tokens=1,2" %%I in (%releases_dir%\start_erl.data) do @(
    @call :set_trim erts_version %%I
    @call :set_trim release_version %%J
)

@set erts_bin=%node_root%\erts-%erts_version%\bin

@set service_name=%node_name%_%release_version%

@if "%1"=="install" @goto install
@if "%1"=="uninstall" @goto uninstall
@if "%1"=="start" @goto start
@if "%1"=="stop" @goto stop
@if "%1"=="restart" @call :stop && @goto start
@rem TODO: attach, ping, restart and reboot

:usage
@echo Usage: %0 {install|uninstall|start|stop|restart}
@goto :EOF

:install
@%erts_bin%\erlsrv.exe add %service_name% -c "Erlang node %node_name% in %node_root%" -w %node_root% -m %node_root%\bin\start_erl.cmd -args " ++ %node_name% ++ %node_root%" -stopaction "init:stop()."
@goto :EOF

:uninstall
@%erts_bin%\erlsrv.exe remove %service_name%
@%erts_bin%\epmd.exe -kill
@goto :EOF

:start
@%erts_bin%\erlsrv.exe start %service_name%
@goto :EOF

:stop
@%erts_bin%\erlsrv.exe stop %service_name%
@goto :EOF

:set_trim
@set %1=%2
@goto :EOF