Merge pull request #7104 from zmstone/fix-windows-build-5.0
[5.0] Fix windows build
This commit is contained in:
commit
e6380a1911
|
@ -52,18 +52,14 @@ jobs:
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
needs: prepare
|
needs: prepare
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
profile: # only CE for windows
|
profile: # for now only CE for windows
|
||||||
- emqx
|
- emqx
|
||||||
otp:
|
otp:
|
||||||
## gleam-lang/setup-erlang does not yet support the installation of otp24 on windows
|
- 24.2.1
|
||||||
- 23.2
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
|
@ -72,8 +68,7 @@ jobs:
|
||||||
- name: unzip source code
|
- name: unzip source code
|
||||||
run: Expand-Archive -Path source.zip -DestinationPath ./
|
run: Expand-Archive -Path source.zip -DestinationPath ./
|
||||||
- uses: ilammy/msvc-dev-cmd@v1
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
- uses: gleam-lang/setup-erlang@v1.1.2
|
- uses: erlef/setup-beam@v1
|
||||||
id: install_erlang
|
|
||||||
with:
|
with:
|
||||||
otp-version: ${{ matrix.otp }}
|
otp-version: ${{ matrix.otp }}
|
||||||
- name: build
|
- name: build
|
||||||
|
@ -82,44 +77,26 @@ jobs:
|
||||||
DIAGNOSTIC: 1
|
DIAGNOSTIC: 1
|
||||||
working-directory: source
|
working-directory: source
|
||||||
run: |
|
run: |
|
||||||
$env:PATH = "${{ steps.install_erlang.outputs.erlpath }}\bin;$env:PATH"
|
# ensure crypto app (openssl)
|
||||||
|
erl -eval "erlang:display(crypto:info_lib())" -s init stop
|
||||||
$version = $( "${{ github.ref }}" -replace "^(.*)/(.*)/" )
|
make ${{ matrix.profile }}-tgz
|
||||||
if ($version -match "^v[0-9]+\.[0-9]+(\.[0-9]+)?") {
|
|
||||||
$regex = "[0-9]+\.[0-9]+(-alpha|-beta|-rc)?\.[0-9]+"
|
|
||||||
$pkg_name = "${{ matrix.profile }}-$([regex]::matches($version, $regex).value)-otp${{ matrix.otp }}-windows-amd64.tar.gz"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$pkg_name = "${{ matrix.profile }}-$($version -replace '/')-otp${{ matrix.otp }}-windows-amd64.tar.gz"
|
|
||||||
}
|
|
||||||
## We do not build/release bcrypt and quic for windows package
|
|
||||||
Remove-Item -Recurse -Force -Path _build/default/lib/bcrypt/
|
|
||||||
Remove-Item -Recurse -Force -Path _build/default/lib/quicer/
|
|
||||||
if (Test-Path rebar.lock) {
|
|
||||||
Remove-Item -Force -Path rebar.lock
|
|
||||||
}
|
|
||||||
make ensure-rebar3
|
|
||||||
copy rebar3 "${{ steps.install_erlang.outputs.erlpath }}\bin"
|
|
||||||
ls "${{ steps.install_erlang.outputs.erlpath }}\bin"
|
|
||||||
rebar3 --help
|
|
||||||
make ${{ matrix.profile }}
|
|
||||||
mkdir -p _packages/${{ matrix.profile }}
|
|
||||||
Compress-Archive -Path _build/${{ matrix.profile }}/rel/emqx -DestinationPath _build/${{ matrix.profile }}/rel/$pkg_name
|
|
||||||
mv _build/${{ matrix.profile }}/rel/$pkg_name _packages/${{ matrix.profile }}
|
|
||||||
Get-FileHash -Path "_packages/${{ matrix.profile }}/$pkg_name" | Format-List | grep 'Hash' | awk '{print $3}' > _packages/${{ matrix.profile }}/$pkg_name.sha256
|
|
||||||
- name: run emqx
|
- name: run emqx
|
||||||
timeout-minutes: 1
|
timeout-minutes: 5
|
||||||
working-directory: source
|
working-directory: source
|
||||||
run: |
|
run: |
|
||||||
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start
|
||||||
Start-Sleep -s 5
|
Start-Sleep -s 5
|
||||||
|
echo "EMQX started"
|
||||||
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop
|
||||||
|
echo "EMQX stopped"
|
||||||
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install
|
||||||
|
echo "EMQX installed"
|
||||||
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx uninstall
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx uninstall
|
||||||
|
echo "EMQX uninstalled"
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.profile }}
|
name: ${{ matrix.profile }}-windows
|
||||||
path: source/_packages/${{ matrix.profile }}/.
|
path: source/_packages/${{ matrix.profile }}/.
|
||||||
|
|
||||||
mac:
|
mac:
|
||||||
|
@ -209,7 +186,6 @@ jobs:
|
||||||
./emqx/bin/emqx_ctl status
|
./emqx/bin/emqx_ctl status
|
||||||
./emqx/bin/emqx stop
|
./emqx/bin/emqx stop
|
||||||
rm -rf emqx
|
rm -rf emqx
|
||||||
openssl dgst -sha256 $pkg_name | awk '{print $2}' > $pkg_name.sha256
|
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
|
@ -354,19 +330,6 @@ jobs:
|
||||||
--system "${SYSTEM}" \
|
--system "${SYSTEM}" \
|
||||||
--builder "ghcr.io/emqx/emqx-builder/5.0-5:${ELIXIR}-${OTP}-${SYSTEM}"
|
--builder "ghcr.io/emqx/emqx-builder/5.0-5:${ELIXIR}-${OTP}-${SYSTEM}"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: create sha256
|
|
||||||
env:
|
|
||||||
PROFILE: ${{ matrix.profile}}
|
|
||||||
working-directory: source
|
|
||||||
run: |
|
|
||||||
if [ -d _packages/$PROFILE ]; then
|
|
||||||
cd _packages/$PROFILE
|
|
||||||
for var in $(ls emqx-* ); do
|
|
||||||
bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"
|
|
||||||
done
|
|
||||||
cd -
|
|
||||||
fi
|
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
|
@ -655,7 +618,9 @@ jobs:
|
||||||
- emqx-enterprise
|
- emqx-enterprise
|
||||||
otp:
|
otp:
|
||||||
- 24.1.5-4
|
- 24.1.5-4
|
||||||
|
include:
|
||||||
|
- profile: emqx
|
||||||
|
otp: windows # otp version on windows is rather fixed
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: get_version
|
- name: get_version
|
||||||
|
|
|
@ -96,6 +96,43 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.profile}}-${{ matrix.otp }}-${{ matrix.os }}
|
name: ${{ matrix.profile}}-${{ matrix.otp }}-${{ matrix.os }}
|
||||||
path: _packages/${{ matrix.profile}}/*.tar.gz
|
path: _packages/${{ matrix.profile}}/*.tar.gz
|
||||||
|
|
||||||
|
windows:
|
||||||
|
runs-on: windows-2019
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
profile:
|
||||||
|
- emqx
|
||||||
|
otp:
|
||||||
|
- 24.2.1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
- uses: erlef/setup-beam@v1
|
||||||
|
with:
|
||||||
|
otp-version: ${{ matrix.otp }}
|
||||||
|
- name: build
|
||||||
|
env:
|
||||||
|
PYTHON: python
|
||||||
|
DIAGNOSTIC: 1
|
||||||
|
run: |
|
||||||
|
# ensure crypto app (openssl)
|
||||||
|
erl -eval "erlang:display(crypto:info_lib())" -s init stop
|
||||||
|
make ${{ matrix.profile }}-tgz
|
||||||
|
- name: run emqx
|
||||||
|
timeout-minutes: 5
|
||||||
|
run: |
|
||||||
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start
|
||||||
|
Start-Sleep -s 5
|
||||||
|
echo "EMQX started"
|
||||||
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop
|
||||||
|
echo "EMQX stopped"
|
||||||
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install
|
||||||
|
echo "EQMX installed"
|
||||||
|
./_build/${{ matrix.profile }}/rel/emqx/bin/emqx uninstall
|
||||||
|
echo "EQMX uninstaled"
|
||||||
|
|
||||||
mac:
|
mac:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
|
@ -29,7 +29,7 @@ The second path is for CMD to setup environment variables.
|
||||||
|
|
||||||
### Erlang/OTP
|
### Erlang/OTP
|
||||||
|
|
||||||
Install Erlang/OTP 23.2 from https://www.erlang.org/downloads
|
Install Erlang/OTP 24 from https://www.erlang.org/downloads
|
||||||
You may need to edit the `Path` environment variable to allow running
|
You may need to edit the `Path` environment variable to allow running
|
||||||
Erlang commands such as `erl` from powershell.
|
Erlang commands such as `erl` from powershell.
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ e.g.
|
||||||
|
|
||||||
```
|
```
|
||||||
PS C:\Users\zmsto> erl
|
PS C:\Users\zmsto> erl
|
||||||
Eshell V11.1.4 (abort with ^G)
|
Eshell V12.2.1 (abort with ^G)
|
||||||
1> halt().
|
1> halt().
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -148,8 +148,8 @@ start_listener(Type, ListenerName, #{bind := Bind} = Conf) ->
|
||||||
case do_start_listener(Type, ListenerName, Conf) of
|
case do_start_listener(Type, ListenerName, Conf) of
|
||||||
{ok, {skipped, Reason}} when Reason =:= listener_disabled;
|
{ok, {skipped, Reason}} when Reason =:= listener_disabled;
|
||||||
Reason =:= quic_app_missing ->
|
Reason =:= quic_app_missing ->
|
||||||
console_print("- Skip - starting listener ~ts on ~ts ~n due to ~p",
|
console_print("Listener ~ts is NOT started due to: ~p~n.",
|
||||||
[listener_id(Type, ListenerName), format_addr(Bind), Reason]);
|
[listener_id(Type, ListenerName), Reason]);
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
console_print("Listener ~ts on ~ts started.~n",
|
console_print("Listener ~ts on ~ts started.~n",
|
||||||
[listener_id(Type, ListenerName), format_addr(Bind)]);
|
[listener_id(Type, ListenerName), format_addr(Bind)]);
|
||||||
|
|
160
bin/emqx.cmd
160
bin/emqx.cmd
|
@ -8,8 +8,10 @@
|
||||||
:: * restart - run the stop command and start command
|
:: * restart - run the stop command and start command
|
||||||
:: * uninstall - uninstall the service and kill a running node
|
:: * uninstall - uninstall the service and kill a running node
|
||||||
:: * ping - check if the node is running
|
:: * ping - check if the node is running
|
||||||
|
:: * ctl - run management commands
|
||||||
:: * console - start the Erlang release in a `werl` Windows shell
|
:: * console - start the Erlang release in a `werl` Windows shell
|
||||||
:: * attach - connect to a running node and open an interactive console
|
:: * attach - connect to a running node and open an interactive console
|
||||||
|
:: * remote_console - same as attach
|
||||||
:: * list - display a listing of installed Erlang services
|
:: * list - display a listing of installed Erlang services
|
||||||
:: * usage - display available commands
|
:: * usage - display available commands
|
||||||
|
|
||||||
|
@ -22,7 +24,9 @@
|
||||||
|
|
||||||
@set script=%~n0
|
@set script=%~n0
|
||||||
|
|
||||||
|
:: for remote_console
|
||||||
@set EPMD_ARG=-start_epmd false -epmd_module ekka_epmd -proto_dist ekka
|
@set EPMD_ARG=-start_epmd false -epmd_module ekka_epmd -proto_dist ekka
|
||||||
|
:: for erl command
|
||||||
@set ERL_FLAGS=%EPMD_ARG%
|
@set ERL_FLAGS=%EPMD_ARG%
|
||||||
|
|
||||||
:: Discover the release root directory from the directory
|
:: Discover the release root directory from the directory
|
||||||
|
@ -32,43 +36,54 @@
|
||||||
set rel_root_dir=%%~fA
|
set rel_root_dir=%%~fA
|
||||||
)
|
)
|
||||||
|
|
||||||
@set rel_dir=%rel_root_dir%\releases\%rel_vsn%
|
:: If release dir has space, change dir
|
||||||
@set RUNNER_ROOT_DIR=%rel_root_dir%
|
@if not "%rel_root_dir%"=="%rel_root_dir: =%" (
|
||||||
@set RUNNER_ETC_DIR=%rel_root_dir%\etc
|
@chdir /d "%rel_root_dir%"
|
||||||
|
@set rel_root_dir=.
|
||||||
|
)
|
||||||
|
|
||||||
@set etc_dir=%rel_root_dir%\etc
|
@set "erts_dir=%rel_root_dir%\erts-%erts_vsn%"
|
||||||
@set lib_dir=%rel_root_dir%\lib
|
@set "rootdir=%rel_root_dir%"
|
||||||
@set data_dir=%rel_root_dir%\data
|
@set "rel_dir=%rel_root_dir%\releases\%rel_vsn%"
|
||||||
@set emqx_conf=%etc_dir%\emqx.conf
|
@set "RUNNER_ROOT_DIR=%rel_root_dir%"
|
||||||
|
:: hard code etc dir
|
||||||
|
@set "RUNNER_ETC_DIR=%rel_root_dir%\etc"
|
||||||
|
@set "etc_dir=%rel_root_dir%\etc"
|
||||||
|
@set "lib_dir=%rel_root_dir%\lib"
|
||||||
|
:: allow setting data dir
|
||||||
|
@if "%RUNNER_DATA_DIR%"=="" (
|
||||||
|
@set "data_dir=%rel_root_dir%\data"
|
||||||
|
) else (
|
||||||
|
@set "data_dir=%RUNNER_DATA_DIR%"
|
||||||
|
)
|
||||||
|
@set "emqx_conf=%etc_dir%\emqx.conf"
|
||||||
|
|
||||||
@call :find_erts_dir
|
@set "boot_file_name=%rel_dir%\start"
|
||||||
@call :find_vm_args
|
@set "service_name=%rel_name%_%rel_vsn%"
|
||||||
@call :find_sys_config
|
@set "bindir=%erts_dir%\bin"
|
||||||
@call :set_boot_script_var
|
|
||||||
|
|
||||||
@set service_name=%rel_name%_%rel_vsn%
|
|
||||||
@set bindir=%erts_dir%\bin
|
|
||||||
@set progname=erl.exe
|
@set progname=erl.exe
|
||||||
@set clean_boot_script=%rel_root_dir%\bin\start_clean
|
@set "clean_boot_file_name=%rel_dir%\start_clean"
|
||||||
@set erlsrv="%bindir%\erlsrv.exe"
|
@set "erlsrv=%bindir%\erlsrv.exe"
|
||||||
@set escript="%bindir%\escript.exe"
|
@set "escript=%bindir%\escript.exe"
|
||||||
@set werl="%bindir%\werl.exe"
|
@set "werl=%bindir%\werl.exe"
|
||||||
@set erl_exe="%bindir%\erl.exe"
|
@set "erl_exe=%bindir%\erl.exe"
|
||||||
@set nodetool="%rel_root_dir%\bin\nodetool"
|
@set "nodetool=%rel_root_dir%\bin\nodetool"
|
||||||
@set cuttlefish="%rel_root_dir%\bin\cuttlefish"
|
@set "cuttlefish=%rel_root_dir%\bin\cuttlefish"
|
||||||
@set node_type="-name"
|
@set node_type=-name
|
||||||
@set schema_mod="emqx_conf_schema"
|
@set schema_mod=emqx_conf_schema
|
||||||
|
|
||||||
@set conf_path="%etc_dir%\emqx.conf"
|
@set conf_path="%etc_dir%\emqx.conf"
|
||||||
:: Extract node name from emqx.conf
|
:: Extract node name from emqx.conf
|
||||||
@for /f "usebackq delims=" %%I in (`"%escript% %nodetool% hocon -s %schema_mod% -c %conf_path% get node.name"`) do @(
|
@for /f "usebackq delims=" %%I in (`"%escript% %nodetool% hocon -s %schema_mod% -c %conf_path% get node.name"`) do @(
|
||||||
@call :set_trim node_name %%I
|
@call :set_trim node_name %%I
|
||||||
)
|
)
|
||||||
|
@set node_name=%node_name:"=%
|
||||||
|
|
||||||
:: Extract node cookie from emqx.conf
|
:: Extract node cookie from emqx.conf
|
||||||
@for /f "usebackq delims=" %%I in (`"%escript% %nodetool% hocon -s %schema_mod% -c %conf_path% get node.cookie"`) do @(
|
@for /f "usebackq delims=" %%I in (`"%escript% %nodetool% hocon -s %schema_mod% -c %conf_path% get node.cookie"`) do @(
|
||||||
@call :set_trim node_cookie %%I
|
@call :set_trim node_cookie %%I
|
||||||
)
|
)
|
||||||
|
@set node_cookie=%node_cookie:"=%
|
||||||
|
|
||||||
:: Write the erl.ini file to set up paths relative to this script
|
:: Write the erl.ini file to set up paths relative to this script
|
||||||
@call :write_ini
|
@call :write_ini
|
||||||
|
@ -83,67 +98,22 @@
|
||||||
@if "%1"=="start" @goto start
|
@if "%1"=="start" @goto start
|
||||||
@if "%1"=="stop" @goto stop
|
@if "%1"=="stop" @goto stop
|
||||||
@if "%1"=="restart" @call :stop && @goto start
|
@if "%1"=="restart" @call :stop && @goto start
|
||||||
::@if "%1"=="upgrade" @goto relup
|
|
||||||
::@if "%1"=="downgrade" @goto relup
|
|
||||||
@if "%1"=="console" @goto console
|
@if "%1"=="console" @goto console
|
||||||
@if "%1"=="ping" @goto ping
|
@if "%1"=="ping" @goto ping
|
||||||
|
@if "%1"=="ctl" @goto ctl
|
||||||
@if "%1"=="list" @goto list
|
@if "%1"=="list" @goto list
|
||||||
@if "%1"=="attach" @goto attach
|
@if "%1"=="attach" @goto attach
|
||||||
|
@if "%1"=="remote_console" @goto attach
|
||||||
@if "%1"=="" @goto usage
|
@if "%1"=="" @goto usage
|
||||||
@echo Unknown command: "%1"
|
@echo Unknown command: "%1"
|
||||||
|
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: Find the ERTS dir
|
|
||||||
:find_erts_dir
|
|
||||||
@set possible_erts_dir=%rel_root_dir%\erts-%erts_vsn%
|
|
||||||
@if exist "%possible_erts_dir%" (
|
|
||||||
call :set_erts_dir_from_default
|
|
||||||
) else (
|
|
||||||
call :set_erts_dir_from_erl
|
|
||||||
)
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Set the ERTS dir from the passed in erts_vsn
|
|
||||||
:set_erts_dir_from_default
|
|
||||||
@set erts_dir=%possible_erts_dir%
|
|
||||||
@set rootdir=%rel_root_dir%
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Set the ERTS dir from erl
|
|
||||||
:set_erts_dir_from_erl
|
|
||||||
@for /f "delims=" %%i in ('where erl') do @(
|
|
||||||
set erl=%%i
|
|
||||||
)
|
|
||||||
@set dir_cmd="%erl%" -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop
|
|
||||||
@for /f %%i in ('%%dir_cmd%%') do @(
|
|
||||||
set erl_root=%%i
|
|
||||||
)
|
|
||||||
@set erts_dir=%erl_root%\erts-%erts_vsn%
|
|
||||||
@set rootdir=%erl_root%
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:find_vm_args
|
|
||||||
@set possible_vm=%etc_dir%\vm.args
|
|
||||||
@if exist "%possible_vm%" (
|
|
||||||
set args_file=-args_file "%possible_vm%"
|
|
||||||
)
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Find the sys.config file
|
|
||||||
:find_sys_config
|
|
||||||
@set possible_sys=%etc_dir%\sys.config
|
|
||||||
@if exist "%possible_sys%" (
|
|
||||||
set sys_config=-config "%possible_sys%"
|
|
||||||
)
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:create_mnesia_dir
|
:create_mnesia_dir
|
||||||
@set create_dir_cmd=%escript% %nodetool% mnesia_dir "%data_dir%\mnesia" %node_name%
|
@set create_dir_cmd=%escript% %nodetool% mnesia_dir "%data_dir%\mnesia" %node_name%
|
||||||
@for /f "delims=" %%Z in ('%%create_dir_cmd%%') do @(
|
@for /f "delims=" %%Z in ('%%create_dir_cmd%%') do @(
|
||||||
set mnesia_dir=%%Z
|
set mnesia_dir=%%Z
|
||||||
)
|
)
|
||||||
@set mnesia_dir="%mnesia_dir%"
|
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: get the current time with hocon
|
:: get the current time with hocon
|
||||||
|
@ -155,7 +125,7 @@
|
||||||
|
|
||||||
:generate_app_config
|
:generate_app_config
|
||||||
@call :get_cur_time
|
@call :get_cur_time
|
||||||
%escript% %nodetool% hocon -v -t %now_time% -s %schema_mod% -c "%etc_dir%\emqx.conf" -d "%data_dir%\configs" generate
|
@%escript% %nodetool% hocon -v -t %now_time% -s %schema_mod% -c "%etc_dir%\emqx.conf" -d "%data_dir%\configs" generate
|
||||||
@set generated_config_args=-config "%data_dir%\configs\app.%now_time%.config" -args_file "%data_dir%\configs\vm.%now_time%.args"
|
@set generated_config_args=-config "%data_dir%\configs\app.%now_time%.config" -args_file "%data_dir%\configs\vm.%now_time%.args"
|
||||||
:: create one new line
|
:: create one new line
|
||||||
@echo.>>"%data_dir%\configs\vm.%now_time%.args"
|
@echo.>>"%data_dir%\configs\vm.%now_time%.args"
|
||||||
|
@ -163,18 +133,9 @@
|
||||||
@echo %node_type% %node_name%>>"%data_dir%\configs\vm.%now_time%.args"
|
@echo %node_type% %node_name%>>"%data_dir%\configs\vm.%now_time%.args"
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: set boot_script variable
|
|
||||||
:set_boot_script_var
|
|
||||||
@if exist "%rel_dir%\%rel_name%.boot" (
|
|
||||||
set boot_script=%rel_dir%\%rel_name%
|
|
||||||
) else (
|
|
||||||
set boot_script=%rel_dir%\start
|
|
||||||
)
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Write the erl.ini file
|
:: Write the erl.ini file
|
||||||
:write_ini
|
:write_ini
|
||||||
@set erl_ini=%erts_dir%\bin\erl.ini
|
@set "erl_ini=%erts_dir%\bin\erl.ini"
|
||||||
@set converted_bindir=%bindir:\=\\%
|
@set converted_bindir=%bindir:\=\\%
|
||||||
@set converted_rootdir=%rootdir:\=\\%
|
@set converted_rootdir=%rootdir:\=\\%
|
||||||
@echo [erlang] > "%erl_ini%"
|
@echo [erlang] > "%erl_ini%"
|
||||||
|
@ -185,7 +146,7 @@
|
||||||
|
|
||||||
:: Display usage information
|
:: Display usage information
|
||||||
:usage
|
:usage
|
||||||
@echo usage: %~n0 ^(install^|uninstall^|start^|stop^|restart^|console^|ping^|list^|attach^)
|
@echo usage: %~n0 ^(install^|uninstall^|start^|stop^|restart^|console^|ping^|ctl^|list^|remote_console^|attach^)
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: Install the release as a Windows service
|
:: Install the release as a Windows service
|
||||||
|
@ -194,16 +155,13 @@
|
||||||
@call :create_mnesia_dir
|
@call :create_mnesia_dir
|
||||||
@call :generate_app_config
|
@call :generate_app_config
|
||||||
:: Install the service
|
:: Install the service
|
||||||
@set args="-boot %boot_script% %sys_config% %generated_config_args% -mnesia dir '%mnesia_dir%'"
|
@set args="-boot %boot_file_name% %generated_config_args% -mnesia dir '%mnesia_dir%'"
|
||||||
@set description=EMQX node %node_name% in %rootdir%
|
@set description=EMQX node %node_name% in %rootdir%
|
||||||
@if "" == "%2" (
|
@if "" == "%2" (
|
||||||
%erlsrv% add %service_name% %node_type% "%node_name%" -on restart -c "%description%" ^
|
%erlsrv% add %service_name% %node_type% "%node_name%" -on restart -c "%description%" ^
|
||||||
-i "emqx" -w "%rootdir%" -m %erl_exe% -args %args% ^
|
-i "emqx" -w "%rootdir%" -m %erl_exe% -args %args% ^
|
||||||
-st "init:stop()."
|
-st "init:stop()."
|
||||||
sc config emqx start=delayed-auto
|
sc config emqx start=delayed-auto
|
||||||
) else (
|
|
||||||
:: relup and reldown
|
|
||||||
goto relup
|
|
||||||
)
|
)
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
|
@ -218,11 +176,11 @@
|
||||||
:: @%erlsrv% start %service_name%
|
:: @%erlsrv% start %service_name%
|
||||||
@call :create_mnesia_dir
|
@call :create_mnesia_dir
|
||||||
@call :generate_app_config
|
@call :generate_app_config
|
||||||
@set args=-detached %sys_config% %generated_config_args% -mnesia dir '%mnesia_dir%'
|
@set args=-detached %generated_config_args% -mnesia dir '%mnesia_dir%'
|
||||||
@echo off
|
@echo off
|
||||||
cd /d "%rel_root_dir%"
|
cd /d "%rel_root_dir%"
|
||||||
@echo on
|
@echo on
|
||||||
@start "%rel_name%" %werl% -boot "%boot_script%" -mode embedded %args%
|
@start "%rel_name%" %werl% -mode embedded -boot "%boot_file_name%" %args%
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: Stop the Windows service
|
:: Stop the Windows service
|
||||||
|
@ -232,27 +190,15 @@ cd /d "%rel_root_dir%"
|
||||||
@%escript% %nodetool% %node_type% %node_name% -setcookie %node_cookie% stop
|
@%escript% %nodetool% %node_type% %node_name% -setcookie %node_cookie% stop
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: Relup and reldown
|
|
||||||
:relup
|
|
||||||
@if "" == "%2" (
|
|
||||||
echo Missing package argument
|
|
||||||
echo Usage: %rel_name% %1 {package base name}
|
|
||||||
echo NOTE {package base name} MUST NOT include the .tar.gz suffix
|
|
||||||
set ERRORLEVEL=1
|
|
||||||
exit /b %ERRORLEVEL%
|
|
||||||
)
|
|
||||||
@%escript% "%rootdir%/bin/install_upgrade.escript" "%rel_name%" "%node_name%" "%node_cookie%" "%2"
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Start a console
|
:: Start a console
|
||||||
:console
|
:console
|
||||||
@call :create_mnesia_dir
|
@call :create_mnesia_dir
|
||||||
@call :generate_app_config
|
@call :generate_app_config
|
||||||
@set args=%sys_config% %generated_config_args% -mnesia dir '%mnesia_dir%'
|
@set args=%generated_config_args% -mnesia dir '%mnesia_dir%'
|
||||||
@echo off
|
@echo off
|
||||||
cd /d %rel_root_dir%
|
cd /d %rel_root_dir%
|
||||||
@echo on
|
@echo on
|
||||||
@start "bin\%rel_name% console" %werl% -boot "%boot_script%" -mode embedded %args%
|
@start "%rel_name% console" %werl% -mode embedded -boot "%boot_file_name%" %args%
|
||||||
@echo emqx is started!
|
@echo emqx is started!
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
|
@ -261,6 +207,12 @@ cd /d %rel_root_dir%
|
||||||
@%escript% %nodetool% ping %node_type% "%node_name%" -setcookie "%node_cookie%"
|
@%escript% %nodetool% ping %node_type% "%node_name%" -setcookie "%node_cookie%"
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
|
:: ctl to execute management commands
|
||||||
|
:ctl
|
||||||
|
@for /f "usebackq tokens=1*" %%i in (`echo %*`) DO @ set params=%%j
|
||||||
|
@%escript% %nodetool% %node_type% "%node_name%" -setcookie "%node_cookie%" rpc_infinity emqx_ctl run_command %params%
|
||||||
|
@goto :eof
|
||||||
|
|
||||||
:: List installed Erlang services
|
:: List installed Erlang services
|
||||||
:list
|
:list
|
||||||
@%erlsrv% list %service_name%
|
@%erlsrv% list %service_name%
|
||||||
|
@ -268,9 +220,7 @@ cd /d %rel_root_dir%
|
||||||
|
|
||||||
:: Attach to a running node
|
:: Attach to a running node
|
||||||
:attach
|
:attach
|
||||||
:: @start "%node_name% attach"
|
@start "remsh_%nodename%" %werl% -hidden -remsh "%node_name%" -boot "%clean_boot_file_name%" "%node_type%" "remsh_%node_name%" -setcookie "%node_cookie%"
|
||||||
@start "%node_name% attach" %werl% -boot "%clean_boot_script%" ^
|
|
||||||
-remsh %node_name% %node_type% console_%node_name% -setcookie %node_cookie%
|
|
||||||
@goto :eof
|
@goto :eof
|
||||||
|
|
||||||
:: Trim variable
|
:: Trim variable
|
||||||
|
|
|
@ -1,92 +1,11 @@
|
||||||
:: The batch file for emqx_ctl command
|
:: The batch file for 'emqx ctl' command
|
||||||
|
|
||||||
@set args=%*
|
@set args=%*
|
||||||
|
|
||||||
:: Set variables that describe the release
|
|
||||||
@set rel_name=emqx
|
|
||||||
@set rel_vsn={{ release_version }}
|
|
||||||
@set erts_vsn={{ erts_vsn }}
|
|
||||||
@set erl_opts={{ erl_opts }}
|
|
||||||
|
|
||||||
:: Discover the release root directory from the directory
|
:: Discover the release root directory from the directory
|
||||||
:: of this script
|
:: of this script
|
||||||
@set script_dir=%~dp0
|
@set script_dir=%~dp0
|
||||||
@for %%A in ("%script_dir%\..") do @(
|
@for %%A in ("%script_dir%\..") do @(
|
||||||
set rel_root_dir=%%~fA
|
set rel_root_dir=%%~fA
|
||||||
)
|
)
|
||||||
@set rel_dir=%rel_root_dir%\releases\%rel_vsn%
|
@%rel_root_dir%\bin\emqx.cmd ctl %args%
|
||||||
@set emqx_conf=%rel_root_dir%\etc\emqx.conf
|
|
||||||
|
|
||||||
@call :find_erts_dir
|
|
||||||
|
|
||||||
@set bindir=%erts_dir%\bin
|
|
||||||
@set progname=erl.exe
|
|
||||||
@set escript="%bindir%\escript.exe"
|
|
||||||
@set nodetool="%rel_root_dir%\bin\nodetool"
|
|
||||||
@set node_type="-name"
|
|
||||||
|
|
||||||
:: Extract node name from emqx.conf
|
|
||||||
@for /f "usebackq delims=\= tokens=2" %%I in (`findstr /b node\.name "%emqx_conf%"`) do @(
|
|
||||||
@call :set_trim node_name %%I
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Extract node cookie from emqx.conf
|
|
||||||
@for /f "usebackq delims=\= tokens=2" %%I in (`findstr /b node\.cookie "%emqx_conf%"`) do @(
|
|
||||||
@call :set_trim node_cookie= %%I
|
|
||||||
)
|
|
||||||
|
|
||||||
:: Write the erl.ini file to set up paths relative to this script
|
|
||||||
@call :write_ini
|
|
||||||
|
|
||||||
:: If a start.boot file is not present, copy one from the named .boot file
|
|
||||||
@if not exist "%rel_dir%\start.boot" (
|
|
||||||
copy "%rel_dir%\%rel_name%.boot" "%rel_dir%\start.boot" >nul
|
|
||||||
)
|
|
||||||
|
|
||||||
@%escript% %nodetool% %node_type% "%node_name%" -setcookie "%node_cookie%" rpc emqx_ctl run_command %args%
|
|
||||||
|
|
||||||
:: Find the ERTS dir
|
|
||||||
:find_erts_dir
|
|
||||||
@set possible_erts_dir=%rel_root_dir%\erts-%erts_vsn%
|
|
||||||
@if exist "%possible_erts_dir%" (
|
|
||||||
call :set_erts_dir_from_default
|
|
||||||
) else (
|
|
||||||
call :set_erts_dir_from_erl
|
|
||||||
)
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Set the ERTS dir from the passed in erts_vsn
|
|
||||||
:set_erts_dir_from_default
|
|
||||||
@set erts_dir=%possible_erts_dir%
|
|
||||||
@set rootdir=%rel_root_dir%
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Set the ERTS dir from erl
|
|
||||||
:set_erts_dir_from_erl
|
|
||||||
@for /f "delims=" %%i in ('where erl') do @(
|
|
||||||
set erl=%%i
|
|
||||||
)
|
|
||||||
@set dir_cmd="%erl%" -noshell -eval "io:format(\"~s\", [filename:nativename(code:root_dir())])." -s init stop
|
|
||||||
@for /f %%i in ('%%dir_cmd%%') do @(
|
|
||||||
set erl_root=%%i
|
|
||||||
)
|
|
||||||
@set erts_dir=%erl_root%\erts-%erts_vsn%
|
|
||||||
@set rootdir=%erl_root%
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Write the erl.ini file
|
|
||||||
:write_ini
|
|
||||||
@set erl_ini=%erts_dir%\bin\erl.ini
|
|
||||||
@set converted_bindir=%bindir:\=\\%
|
|
||||||
@set converted_rootdir=%rootdir:\=\\%
|
|
||||||
@echo [erlang] > "%erl_ini%"
|
|
||||||
@echo Bindir=%converted_bindir% >> "%erl_ini%"
|
|
||||||
@echo Progname=%progname% >> "%erl_ini%"
|
|
||||||
@echo Rootdir=%converted_rootdir% >> "%erl_ini%"
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
:: Trim variable
|
|
||||||
:set_trim
|
|
||||||
@set %1=%2
|
|
||||||
@goto :eof
|
|
||||||
|
|
||||||
|
|
42
build
42
build
|
@ -78,8 +78,7 @@ make_doc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
make_rel() {
|
make_rel() {
|
||||||
# shellcheck disable=SC1010
|
./rebar3 as "$PROFILE" tar
|
||||||
./rebar3 as "$PROFILE" do tar
|
|
||||||
if [ "$("$FIND" "_build/$PROFILE/rel/emqx/lib/" -maxdepth 1 -name 'gpb-*' -type d)" != "" ]; then
|
if [ "$("$FIND" "_build/$PROFILE/rel/emqx/lib/" -maxdepth 1 -name 'gpb-*' -type d)" != "" ]; then
|
||||||
echo "gpb should not be included in the release"
|
echo "gpb should not be included in the release"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -132,40 +131,55 @@ cp_dyn_libs() {
|
||||||
## It assumes the .tar.gz has been built -- relies on Makefile dependency
|
## It assumes the .tar.gz has been built -- relies on Makefile dependency
|
||||||
make_tgz() {
|
make_tgz() {
|
||||||
local pkgpath="_packages/${PROFILE}"
|
local pkgpath="_packages/${PROFILE}"
|
||||||
local tarball
|
local src_tarball
|
||||||
|
local target_name
|
||||||
local target
|
local target
|
||||||
|
|
||||||
if [ "${IS_ELIXIR:-no}" = "yes" ]
|
if [ "${IS_ELIXIR:-no}" = "yes" ]
|
||||||
then
|
then
|
||||||
# ensure tarball exists
|
# ensure src_tarball exists
|
||||||
ELIXIR_MAKE_TAR=yes make_elixir_rel
|
ELIXIR_MAKE_TAR=yes make_elixir_rel
|
||||||
|
|
||||||
local relpath="_build/${PROFILE}"
|
local relpath="_build/${PROFILE}"
|
||||||
target="${pkgpath}/${PROFILE}-${PKG_VSN}-elixir${ELIXIR_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.tar.gz"
|
target_name="${PROFILE}-${PKG_VSN}-elixir${ELIXIR_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.tar.gz"
|
||||||
else
|
else
|
||||||
# build the tarball again to ensure relup is included
|
# build the src_tarball again to ensure relup is included
|
||||||
# elixir does not have relup yet.
|
# elixir does not have relup yet.
|
||||||
make_rel
|
make_rel
|
||||||
|
|
||||||
local relpath="_build/${PROFILE}/rel/emqx"
|
local relpath="_build/${PROFILE}/rel/emqx"
|
||||||
target="${pkgpath}/${PROFILE}-${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.tar.gz"
|
target_name="${PROFILE}-${PKG_VSN}-otp${OTP_VSN}-${SYSTEM}-${ARCH}.tar.gz"
|
||||||
fi
|
fi
|
||||||
|
target="${pkgpath}/${target_name}"
|
||||||
|
|
||||||
tarball="${relpath}/emqx-${PKG_VSN}.tar.gz"
|
src_tarball="${relpath}/emqx-${PKG_VSN}.tar.gz"
|
||||||
tard="/tmp/emqx_untar_${PKG_VSN}"
|
tard="tmp/emqx_untar_${PKG_VSN}"
|
||||||
rm -rf "${tard}"
|
rm -rf "${tard}"
|
||||||
mkdir -p "${tard}/emqx"
|
mkdir -p "${tard}/emqx"
|
||||||
|
|
||||||
mkdir -p "${pkgpath}"
|
mkdir -p "${pkgpath}"
|
||||||
if [ ! -f "$tarball" ]; then
|
if [ ! -f "$src_tarball" ]; then
|
||||||
log "ERROR: $tarball is not found"
|
log "ERROR: $src_tarball is not found"
|
||||||
fi
|
fi
|
||||||
tar zxf "${tarball}" -C "${tard}/emqx"
|
tar zxf "${src_tarball}" -C "${tard}/emqx"
|
||||||
## try to be portable for tar.gz packages.
|
## try to be portable for tar.gz packages.
|
||||||
## for DEB and RPM packages the dependencies are resoved by yum and apt
|
## for DEB and RPM packages the dependencies are resoved by yum and apt
|
||||||
cp_dyn_libs "${tard}/emqx"
|
cp_dyn_libs "${tard}/emqx"
|
||||||
(cd "${tard}" && tar -cz emqx) > "${target}"
|
## create tar after change dir (for windows)
|
||||||
|
pushd "${tard}" >/dev/null
|
||||||
|
tar -czf "${target_name}" emqx
|
||||||
|
popd >/dev/null
|
||||||
|
mv "${tard}/${target_name}" "${target}"
|
||||||
|
case "$SYSTEM" in
|
||||||
|
macos*)
|
||||||
|
# sha256sum may not be available on macos
|
||||||
|
openssl dgst -sha256 "${target}" | cut -d ' ' -f 2 > "${target}.sha256"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
sha256sum "${target}" | head -c 64 > "${target}.sha256"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
log "Tarball successfully repacked: ${target}"
|
log "Tarball successfully repacked: ${target}"
|
||||||
|
log "Tarball sha256sum: $(cat "${target}.sha256")"
|
||||||
}
|
}
|
||||||
|
|
||||||
## This function builds the default docker image based on alpine:3.14 (by default)
|
## This function builds the default docker image based on alpine:3.14 (by default)
|
||||||
|
|
|
@ -51,7 +51,7 @@ if [ "$SYSTEM" = "macos" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p _upgrade_base
|
mkdir -p _upgrade_base
|
||||||
pushd _upgrade_base
|
pushd _upgrade_base >/dev/null
|
||||||
|
|
||||||
for tag in $(../scripts/relup-base-vsns.sh $EDITION | xargs echo -n); do
|
for tag in $(../scripts/relup-base-vsns.sh $EDITION | xargs echo -n); do
|
||||||
filename="$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.tar.gz"
|
filename="$PROFILE-$SYSTEM-${tag#[e|v]}-$ARCH.tar.gz"
|
||||||
|
@ -67,4 +67,4 @@ for tag in $(../scripts/relup-base-vsns.sh $EDITION | xargs echo -n); do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
popd
|
popd >/dev/null
|
||||||
|
|
Loading…
Reference in New Issue