chore: fix Windows compilation process

This commit is contained in:
Spycsh 2021-09-03 17:25:05 +08:00
parent 7c7892f096
commit c3b980fde9
5 changed files with 34 additions and 20 deletions

1
.gitattributes vendored
View File

@ -1,5 +1,6 @@
* text=auto * text=auto
*.* text eol=lf *.* text eol=lf
*.cmd text eol=crlf
*.jpg -text *.jpg -text
*.png -text *.png -text
*.pdf -text *.pdf -text

2
.gitignore vendored
View File

@ -50,3 +50,5 @@ _upgrade_base/
TAGS TAGS
erlang_ls.config erlang_ls.config
.els_cache/ .els_cache/
.vs/
.vscode/

View File

@ -48,11 +48,6 @@ fields(file) ->
, {enable, #{type => boolean(), , {enable, #{type => boolean(),
default => true}} default => true}}
, {path, #{type => string(), , {path, #{type => string(),
validator => fun(S) -> case filelib:is_file(S) of
true -> ok;
_ -> {error, "File does not exist"}
end
end,
desc => "Path to the file which contains the ACL rules." desc => "Path to the file which contains the ACL rules."
}} }}
]; ];

View File

@ -35,8 +35,12 @@
%% @doc EMQ X boot entrypoint. %% @doc EMQ X boot entrypoint.
start() -> start() ->
os:set_signal(sighup, ignore), case os:type() of
os:set_signal(sigterm, handle), %% default is handle {win32, nt} -> ok;
_nix ->
os:set_signal(sighup, ignore),
os:set_signal(sigterm, handle) %% default is handle
end,
ok = set_backtrace_depth(), ok = set_backtrace_depth(),
ok = print_otp_version_warning(), ok = print_otp_version_warning(),

View File

@ -22,14 +22,19 @@
@set script=%~n0 @set script=%~n0
@set EPMD_ARG=-start_epmd false -epmd_module ekka_epmd -proto_dist ekka
@set ERL_FLAGS=%EPMD_ARG%
:: 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% @set rel_dir=%rel_root_dir%\releases\%rel_vsn%
@set RUNNER_ROOT_DIR=%rel_root_dir% @set RUNNER_ROOT_DIR=%rel_root_dir%
@set RUNNER_ETC_DIR=%rel_root_dir%\etc
@set etc_dir=%rel_root_dir%\etc @set etc_dir=%rel_root_dir%\etc
@set lib_dir=%rel_root_dir%\lib @set lib_dir=%rel_root_dir%\lib
@ -46,22 +51,22 @@
@set progname=erl.exe @set progname=erl.exe
@set clean_boot_script=%rel_root_dir%\bin\start_clean @set clean_boot_script=%rel_root_dir%\bin\start_clean
@set erlsrv="%bindir%\erlsrv.exe" @set erlsrv="%bindir%\erlsrv.exe"
@set epmd="%bindir%\epmd.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_machine_schema"
:: Extract node name from emqx.conf :: Extract node name from emqx.conf
@for /f "usebackq delims=\= tokens=2" %%I in (`findstr /b node\.name "%emqx_conf%"`) do @( @for /f "usebackq delims=" %%I in (`"%escript% %nodetool% hocon -s %schema_mod% -c %etc_dir%\emqx.conf get node.name"`) do @(
@call :set_trim node_name %%I @call :set_trim node_name %%I
) )
:: Extract node cookie from emqx.conf :: Extract node cookie from emqx.conf
@for /f "usebackq delims=\= tokens=2" %%I in (`findstr /b node\.cookie "%emqx_conf%"`) do @( @for /f "usebackq delims=" %%I in (`"%escript% %nodetool% hocon -s %schema_mod% -c %etc_dir%\emqx.conf get node.cookie"`) do @(
@call :set_trim node_cookie= %%I @call :set_trim node_cookie %%I
) )
:: 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
@ -139,13 +144,23 @@
) )
@goto :eof @goto :eof
:generate_app_config :: get the current time with hocon
@set gen_config_cmd=%escript% %cuttlefish% -i %rel_dir%\emqx.schema -c %etc_dir%\emqx.conf -d %data_dir%\configs generate :get_cur_time
@for /f "delims=" %%A in ('%%gen_config_cmd%%') do @( @for /f "usebackq tokens=1-6 delims=." %%a in (`"%escript% %nodetool% hocon now_time"`) do @(
set generated_config_args=%%A set now_time=%%a.%%b.%%c.%%d.%%e.%%f
) )
@goto :eof @goto :eof
:generate_app_config
@call :get_cur_time
%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
:: create one new line
@echo.>>%data_dir%\configs\vm.%now_time%.args
:: write the node type and node name in to vm args file
@echo %node_type% %node_name%>>%data_dir%\configs\vm.%now_time%.args
@goto :eof
:: set boot_script variable :: set boot_script variable
:set_boot_script_var :set_boot_script_var
@if exist "%rel_dir%\%rel_name%.boot" ( @if exist "%rel_dir%\%rel_name%.boot" (
@ -188,13 +203,11 @@
:: relup and reldown :: relup and reldown
goto relup goto relup
) )
@goto :eof @goto :eof
:: Uninstall the Windows service :: Uninstall the Windows service
:uninstall :uninstall
@%erlsrv% remove %service_name% @%erlsrv% remove %service_name%
@%epmd% -kill
@goto :eof @goto :eof
:: Start the Windows service :: Start the Windows service
@ -207,7 +220,7 @@
@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%" %args% @start "%rel_name%" %werl% -boot "%boot_script%" -mode embedded %args%
@goto :eof @goto :eof
:: Stop the Windows service :: Stop the Windows service
@ -237,7 +250,7 @@ cd /d %rel_root_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%" %args% @start "bin\%rel_name% console" %werl% -boot "%boot_script%" -mode embedded %args%
@echo emqx is started! @echo emqx is started!
@goto :eof @goto :eof
@ -262,4 +275,3 @@ cd /d %rel_root_dir%
:set_trim :set_trim
@set %1=%2 @set %1=%2
@goto :eof @goto :eof