2011-08-10 15:32:26 +00:00
|
|
|
@setlocal
|
|
|
|
|
|
|
|
@set node_name={{nodeid}}
|
|
|
|
|
2012-01-09 22:37:44 +00:00
|
|
|
@rem Get the absolute path to the parent directory,
|
2011-08-10 19:29:31 +00:00
|
|
|
@rem which is assumed to be the node root.
|
2011-08-10 15:32:26 +00:00
|
|
|
@for /F "delims=" %%I in ("%~dp0..") do @set node_root=%%~fI
|
|
|
|
|
|
|
|
@set releases_dir=%node_root%\releases
|
|
|
|
|
2011-08-10 19:29:31 +00:00
|
|
|
@rem Parse ERTS version and release version from start_erl.data
|
2011-08-10 15:32:26 +00:00
|
|
|
@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
|
|
|
|
)
|
|
|
|
|
2012-01-09 22:37:44 +00:00
|
|
|
@rem extract erlang cookie from vm.args
|
|
|
|
@set vm_args=%releases_dir%\%release_version%\vm.args
|
|
|
|
@for /f "usebackq tokens=1-2" %%I in (`findstr /b \-setcookie %vm_args%`) do @set erlang_cookie=%%J
|
|
|
|
|
2011-08-10 15:32:26 +00:00
|
|
|
@set erts_bin=%node_root%\erts-%erts_version%\bin
|
|
|
|
|
|
|
|
@set service_name=%node_name%_%release_version%
|
|
|
|
|
2012-01-09 22:37:44 +00:00
|
|
|
@if "%1"=="usage" @goto usage
|
2011-08-10 15:32:26 +00:00
|
|
|
@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
|
2011-09-20 15:11:33 +00:00
|
|
|
@if "%1"=="console" @goto console
|
2012-01-09 22:37:44 +00:00
|
|
|
@if "%1"=="query" @goto query
|
|
|
|
@if "%1"=="attach" @goto attach
|
|
|
|
@if "%1"=="upgrade" @goto upgrade
|
|
|
|
@echo Unknown command: "%1"
|
2011-08-10 15:32:26 +00:00
|
|
|
|
|
|
|
:usage
|
2012-02-28 17:52:36 +00:00
|
|
|
@echo Usage: %~n0 [install^|uninstall^|start^|stop^|restart^|console^|query^|attach^|upgrade]
|
2011-08-10 15:32:26 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:install
|
2011-12-29 20:27:14 +00:00
|
|
|
@%erts_bin%\erlsrv.exe add %service_name% -c "Erlang node %node_name% in %node_root%" -sname %node_name% -w %node_root% -m %node_root%\bin\start_erl.cmd -args " ++ %node_name% ++ %node_root%" -stopaction "init:stop()."
|
2011-08-10 15:32:26 +00:00
|
|
|
@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
|
|
|
|
|
2011-09-20 15:11:33 +00:00
|
|
|
:console
|
2012-01-09 22:37:44 +00:00
|
|
|
@start %erts_bin%\werl.exe -boot %releases_dir%\%release_version%\%node_name% -config %releases_dir%\%release_version%\sys.config -args_file %vm_args% -sname %node_name%
|
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:query
|
|
|
|
@%erts_bin%\erlsrv.exe list %service_name%
|
|
|
|
@exit /b %ERRORLEVEL%
|
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:attach
|
|
|
|
@for /f "usebackq" %%I in (`hostname`) do @set hostname=%%I
|
|
|
|
start %erts_bin%\werl.exe -boot %releases_dir%\%release_version%\start_clean -remsh %node_name%@%hostname% -sname console -setcookie %erlang_cookie%
|
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:upgrade
|
|
|
|
@if "%2"=="" (
|
|
|
|
@echo Missing upgrade package argument
|
|
|
|
@echo Usage: %~n0 upgrade {package base name}
|
|
|
|
@echo NOTE {package base name} MUST NOT include the .tar.gz suffix
|
|
|
|
@goto :EOF
|
|
|
|
)
|
|
|
|
@%erts_bin%\escript.exe %node_root%\bin\install_upgrade.escript %node_name% %erlang_cookie% %2
|
2011-09-20 15:11:33 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
2011-08-10 15:32:26 +00:00
|
|
|
:set_trim
|
|
|
|
@set %1=%2
|
|
|
|
@goto :EOF
|