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
|
2012-07-30 19:30:05 +00:00
|
|
|
@for /F "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
|
2011-08-10 15:32:26 +00:00
|
|
|
@call :set_trim erts_version %%I
|
|
|
|
@call :set_trim release_version %%J
|
|
|
|
)
|
|
|
|
|
2012-01-09 22:37:44 +00:00
|
|
|
@set vm_args=%releases_dir%\%release_version%\vm.args
|
2012-07-30 19:30:05 +00:00
|
|
|
@set sys_config=%releases_dir%\%release_version%\sys.config
|
|
|
|
@set node_boot_script=%releases_dir%\%release_version%\%node_name%
|
|
|
|
@set clean_boot_script=%releases_dir%\%release_version%\start_clean
|
|
|
|
|
|
|
|
@rem extract erlang cookie from vm.args
|
|
|
|
@for /f "usebackq tokens=1-2" %%I in (`findstr /b \-setcookie "%vm_args%"`) do @set erlang_cookie=%%J
|
2012-01-09 22:37:44 +00:00
|
|
|
|
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-07-30 19:30:05 +00:00
|
|
|
@set erlsrv="%erts_bin%\erlsrv.exe"
|
|
|
|
@set epmd="%erts_bin%\epmd.exe"
|
|
|
|
@set escript="%erts_bin%\escript.exe"
|
|
|
|
@set werl="%erts_bin%\werl.exe"
|
2013-05-19 19:40:44 +00:00
|
|
|
@set nodetool="%erts_bin%\nodetool"
|
2012-07-30 19:30:05 +00:00
|
|
|
|
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
|
2013-05-19 19:40:44 +00:00
|
|
|
@if "%1"=="ping" @goto ping
|
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
|
2013-05-19 19:40:44 +00:00
|
|
|
@echo Usage: %~n0 [install^|uninstall^|start^|stop^|restart^|console^|ping^|query^|attach^|upgrade]
|
2011-08-10 15:32:26 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:install
|
2012-07-30 19:30:05 +00:00
|
|
|
@set description=Erlang node %node_name% in %node_root%
|
|
|
|
@set start_erl=%node_root%\bin\start_erl.cmd
|
|
|
|
@set args= ++ %node_name% ++ %node_root%
|
|
|
|
@%erlsrv% add %service_name% -c "%description%" -sname %node_name% -w "%node_root%" -m "%start_erl%" -args "%args%" -stopaction "init:stop()."
|
2011-08-10 15:32:26 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:uninstall
|
2012-07-30 19:30:05 +00:00
|
|
|
@%erlsrv% remove %service_name%
|
|
|
|
@%epmd% -kill
|
2011-08-10 15:32:26 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:start
|
2012-07-30 19:30:05 +00:00
|
|
|
@%erlsrv% start %service_name%
|
2011-08-10 15:32:26 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:stop
|
2012-07-30 19:30:05 +00:00
|
|
|
@%erlsrv% stop %service_name%
|
2011-08-10 15:32:26 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
2011-09-20 15:11:33 +00:00
|
|
|
:console
|
2012-07-30 19:30:05 +00:00
|
|
|
@start "%node_name% console" %werl% -boot "%node_boot_script%" -config "%sys_config%" -args_file "%vm_args%" -sname %node_name%
|
2012-01-09 22:37:44 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
2013-05-19 19:40:44 +00:00
|
|
|
:ping
|
|
|
|
@%escript% %nodetool% ping -sname "%node_name%" -setcookie "%erlang_cookie%"
|
|
|
|
@exit %ERRORLEVEL%
|
|
|
|
@goto :EOF
|
|
|
|
|
2012-01-09 22:37:44 +00:00
|
|
|
:query
|
2012-07-30 19:30:05 +00:00
|
|
|
@%erlsrv% list %service_name%
|
|
|
|
@exit %ERRORLEVEL%
|
2012-01-09 22:37:44 +00:00
|
|
|
@goto :EOF
|
|
|
|
|
|
|
|
:attach
|
|
|
|
@for /f "usebackq" %%I in (`hostname`) do @set hostname=%%I
|
2012-07-30 19:30:05 +00:00
|
|
|
start "%node_name% attach" %werl% -boot "%clean_boot_script%" -remsh %node_name%@%hostname% -sname console -setcookie %erlang_cookie%
|
2012-01-09 22:37:44 +00:00
|
|
|
@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
|
|
|
|
)
|
2015-01-20 07:18:10 +00:00
|
|
|
@%escript% %nodetool% -sname "%node_name%" -setcookie "%erlang_cookie%" upgrade %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
|