Skip to content

Commit

Permalink
Merge pull request erlyaws#148 from tuncer/rel-windows
Browse files Browse the repository at this point in the history
rel: add Windows scripts
  • Loading branch information
vinoski committed Sep 3, 2013
2 parents c370a2e + 2652585 commit 41fcce4
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/yaws.tex
Expand Up @@ -220,6 +220,26 @@ \subsection{Compile and Install}

\end{itemize}

Alternatively, you can compile yaws with \verb+rebar+ as follows:
\begin{verbatim}
# rebar get-deps compile
\end{verbatim}

If you want to build with SOAP support, run the following command:
\begin{verbatim}
# YAWS_SOAP=1 rebar get-deps compile
\end{verbatim}

To create a Yaws release with reltool, execute the following command:
\begin{verbatim}
# rebar generate
\end{verbatim}
Because it bundles Erlang/OTP and all of the application's dependencies,
the generated release found in \verb+rel/+ is standalone and has no
external requirements. A future release of \verb+rebar+ will allow you
to create a slim release that doesn't bundle Erlang/OTP. This is not yet
available.

While developing a \Yaws\ site, it's typically most convenient to
use the local\_install and run \Yaws\ as a non-privileged user.

Expand Down
40 changes: 40 additions & 0 deletions rel/files/start_erl.cmd
@@ -0,0 +1,40 @@
@setlocal

@rem Parse arguments. erlsrv.exe prepends erl arguments prior to first ++.
@rem Other args are position dependent.
@set args="%*"
@for /F "delims=++ tokens=1,2,3" %%I in (%args%) do @(
@set erl_args=%%I
@call :set_trim node_name %%J
@rem Trim spaces from the left of %%K (node_root), which may have spaces inside
@for /f "tokens=* delims= " %%a in ("%%K") do @set node_root=%%a
)

@set releases_dir=%node_root%\releases

@rem parse ERTS version and release version from start_erl.dat
@for /F "usebackq 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%"

@if exist "%releases_dir%\%release_version%\sys.config" (
@set app_config="%releases_dir%\%release_version%\sys.config"
) else (
@set app_config="%node_root%\etc\app.config"
)

@if exist "%releases_dir%\%release_version%\vm.args" (
@set vm_args="%releases_dir%\%release_version%\vm.args"
) else (
@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
103 changes: 103 additions & 0 deletions rel/files/yaws.cmd
@@ -0,0 +1,103 @@
@setlocal

@set node_name=yaws

@rem Get the absolute 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 "usebackq tokens=1,2" %%I in ("%releases_dir%\start_erl.data") do @(
@call :set_trim erts_version %%I
@call :set_trim release_version %%J
)

@set vm_args=%releases_dir%\%release_version%\vm.args
@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

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

@set service_name=%node_name%_%release_version%

@set erlsrv="%erts_bin%\erlsrv.exe"
@set epmd="%erts_bin%\epmd.exe"
@set escript="%erts_bin%\escript.exe"
@set werl="%erts_bin%\werl.exe"
@set nodetool="%erts_bin%\nodetool"

@if "%1"=="usage" @goto usage
@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
@if "%1"=="console" @goto console
@if "%1"=="ping" @goto ping
@if "%1"=="query" @goto query
@if "%1"=="attach" @goto attach
@if "%1"=="upgrade" @goto upgrade
@echo Unknown command: "%1"

:usage
@echo Usage: %~n0 [install^|uninstall^|start^|stop^|restart^|console^|ping^|query^|attach^|upgrade]
@goto :EOF

:install
@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()."
@goto :EOF

:uninstall
@%erlsrv% remove %service_name%
@%epmd% -kill
@goto :EOF

:start
@%erlsrv% start %service_name%
@goto :EOF

:stop
@%erlsrv% stop %service_name%
@goto :EOF

:console
@start "%node_name% console" %werl% -boot "%node_boot_script%" -config "%sys_config%" -args_file "%vm_args%" -sname %node_name%
@goto :EOF

:ping
@%escript% %nodetool% ping -sname "%node_name%" -setcookie "%erlang_cookie%"
@exit %ERRORLEVEL%
@goto :EOF

:query
@%erlsrv% list %service_name%
@exit %ERRORLEVEL%
@goto :EOF

:attach
@for /f "usebackq" %%I in (`hostname`) do @set hostname=%%I
start "%node_name% attach" %werl% -boot "%clean_boot_script%" -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
)
@%escript% %node_root%\bin\install_upgrade.escript %node_name% %erlang_cookie% %2
@goto :EOF

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

0 comments on commit 41fcce4

Please sign in to comment.