diff --git a/priv/templates/simplenode.reltool.config b/priv/templates/simplenode.reltool.config index 6a37b16..4248b9c 100644 --- a/priv/templates/simplenode.reltool.config +++ b/priv/templates/simplenode.reltool.config @@ -25,6 +25,8 @@ {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"}, {copy, "files/{{nodeid}}", "bin/{{nodeid}}"}, + {copy, "files/{{nodeid}}.cmd", "bin/{{nodeid}}.cmd"}, + {copy, "files/start_erl.cmd", "bin/start_erl.cmd"}, {copy, "files/app.config", "etc/app.config"}, {copy, "files/vm.args", "etc/vm.args"} ]}. diff --git a/priv/templates/simplenode.template b/priv/templates/simplenode.template index 95aaa94..974c6f0 100644 --- a/priv/templates/simplenode.template +++ b/priv/templates/simplenode.template @@ -8,3 +8,5 @@ {chmod, 8#744, "files/{{nodeid}}"}. {file, "simplenode.app.config", "files/app.config"}. {template, "simplenode.vm.args", "files/vm.args"}. +{template, "simplenode.windows.runner.cmd", "files/{{nodeid}}.cmd"}. +{file, "simplenode.windows.start_erl.cmd", "files/start_erl.cmd"}. diff --git a/priv/templates/simplenode.windows.runner.cmd b/priv/templates/simplenode.windows.runner.cmd new file mode 100644 index 0000000..366b640 --- /dev/null +++ b/priv/templates/simplenode.windows.runner.cmd @@ -0,0 +1,58 @@ +@rem Do not use "echo off" to not affect any child calls. +@setlocal + +@set node_name={{nodeid}} + +@rem Get the abolute path to the parent directory, 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.dat +@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 @if "%1"=="attach" @goto attach +@rem TODO: 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 + +@rem this relies on a system install of Erlang to be on the PATH. +@rem also, node-naming issues make this difficult to automate +@rem :attach +@rem @werl.exe -remsh %node_name%@localhost -setcookie %COOKIE% -sname console +@rem @goto quit + +:set_trim +@set %1=%2 +@goto :EOF diff --git a/priv/templates/simplenode.windows.start_erl.cmd b/priv/templates/simplenode.windows.start_erl.cmd new file mode 100644 index 0000000..28a0da8 --- /dev/null +++ b/priv/templates/simplenode.windows.start_erl.cmd @@ -0,0 +1,28 @@ +@rem Do not use "echo off" to not affect any child calls. +@setlocal + +@set args="%*" +@for /F "delims=++ tokens=1,2,3" %%I in (%args%) do @( + @call :set_trim erl_args %%I + @call :set_trim node_name %%J + @call :set_trim node_root %%K +) + +@set releases_dir=%node_root%\releases + +@rem parse ERTS version and release version from start_erl.dat +@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 erl_exe=%node_root%\erts-%erts_version%\bin\erl.exe +@set boot_file=%releases_dir%\%release_version%\%node_name% +@set app_config=%node_root%\etc\app.config +@set vm_args=%node_root%\etc\vm.args + +@%erl_exe% %erl_args% -boot %boot_file% -config %app_config% -args_file %vm_args% + +:set_trim +@set %1=%2 +@goto :EOF