From cb5056b2e362aa0b1eb0ccfc6009613426682ed5 Mon Sep 17 00:00:00 2001 From: joewilliams Date: Tue, 20 Sep 2011 09:44:41 -0700 Subject: Get rid of app.config app.config has been a long standing erroneous file in rebar. Erlang/OTP documentation suggests a sys.config file instead. This file is stored in the releases/VSN directory. This does a few things but most importantly it ensures your config (contained in the application environment) survives a hot upgrade. It also has the advantage of allowing the configuration of the application to be versioned along side the application code. This patch flips rebar to use sys.config rather than app.config. Additionally it makes this flip to vm.args as well, making them versioned just like sys.config. This patch also includes runner script changes to support the old etc/app.config config file location and support for Windows. Thanks to mokele for the initial work and kick in the pants to make this finially happen. --- priv/templates/simplenode.app.config | 11 ----------- priv/templates/simplenode.reltool.config | 11 +++++++++-- priv/templates/simplenode.runner | 16 +++++++++++++++- priv/templates/simplenode.sys.config | 11 +++++++++++ priv/templates/simplenode.template | 2 +- priv/templates/simplenode.windows.start_erl.cmd | 14 ++++++++++++-- 6 files changed, 48 insertions(+), 17 deletions(-) delete mode 100644 priv/templates/simplenode.app.config create mode 100644 priv/templates/simplenode.sys.config (limited to 'priv/templates') diff --git a/priv/templates/simplenode.app.config b/priv/templates/simplenode.app.config deleted file mode 100644 index 3b7f6bd..0000000 --- a/priv/templates/simplenode.app.config +++ /dev/null @@ -1,11 +0,0 @@ -[ - %% SASL config - {sasl, [ - {sasl_error_logger, {file, "log/sasl-error.log"}}, - {errlog_type, error}, - {error_logger_mf_dir, "log/sasl"}, % Log directory - {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size - {error_logger_mf_maxfiles, 5} % 5 files max - ]} -]. - diff --git a/priv/templates/simplenode.reltool.config b/priv/templates/simplenode.reltool.config index 4248b9c..dc247cd 100644 --- a/priv/templates/simplenode.reltool.config +++ b/priv/templates/simplenode.reltool.config @@ -13,8 +13,15 @@ ]}, {boot_rel, "{{nodeid}}"}, {profile, embedded}, + {excl_archive_filters, [".*"]}, %% Do not archive built libs {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]}, + + %% Including HiPE can cause issues generating your first upgrade. + %% If you plan to distribute HiPE in your release remove the + %% following line. + {app, hipe, [{incl_cond, exclude}]}, + {app, sasl, [{incl_cond, include}]} ]}. @@ -25,8 +32,8 @@ {copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"}, {copy, "files/nodetool", "\{\{erts_vsn\}\}/bin/nodetool"}, {copy, "files/{{nodeid}}", "bin/{{nodeid}}"}, + {copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"}, {copy, "files/{{nodeid}}.cmd", "bin/{{nodeid}}.cmd"}, {copy, "files/start_erl.cmd", "bin/start_erl.cmd"}, - {copy, "files/app.config", "etc/app.config"}, - {copy, "files/vm.args", "etc/vm.args"} + {copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"} ]}. diff --git a/priv/templates/simplenode.runner b/priv/templates/simplenode.runner index bacce8d..78d6bae 100755 --- a/priv/templates/simplenode.runner +++ b/priv/templates/simplenode.runner @@ -50,6 +50,20 @@ ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin # Setup command to control the node NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG" +# Use releases/VSN/sys.config if it exists otherwise use etc/app.config +if [ -e "$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config" ]; then + CONFIG_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/sys.config" +else + CONFIG_PATH="$RUNNER_ETC_DIR/app.config" +fi + +# Use releases/VSN/vm.args if it exists otherwise use etc/vm.args +if [-e "$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" ]; then + VMARGS_PATH="$RUNNER_BASE_DIR/releases/$APP_VSN/vm.args" +else + VMARGS_PATH="$RUNNER_ETC_DIR/vm.args" +fi + # Check the first argument for instructions case "$1" in start) @@ -147,7 +161,7 @@ case "$1" in BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin EMU=beam PROGNAME=`echo $0 | sed 's/.*\\///'` - CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $RUNNER_ETC_DIR/app.config -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}" + CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $CONFIG_PATH -args_file $VMARGS_PATH -- ${1+"$@"}" export EMU export ROOTDIR export BINDIR diff --git a/priv/templates/simplenode.sys.config b/priv/templates/simplenode.sys.config new file mode 100644 index 0000000..3b7f6bd --- /dev/null +++ b/priv/templates/simplenode.sys.config @@ -0,0 +1,11 @@ +[ + %% SASL config + {sasl, [ + {sasl_error_logger, {file, "log/sasl-error.log"}}, + {errlog_type, error}, + {error_logger_mf_dir, "log/sasl"}, % Log directory + {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size + {error_logger_mf_maxfiles, 5} % 5 files max + ]} +]. + diff --git a/priv/templates/simplenode.template b/priv/templates/simplenode.template index 974c6f0..d074681 100644 --- a/priv/templates/simplenode.template +++ b/priv/templates/simplenode.template @@ -6,7 +6,7 @@ {chmod, 8#744, "files/nodetool"}. {file, "simplenode.runner", "files/{{nodeid}}"}. {chmod, 8#744, "files/{{nodeid}}"}. -{file, "simplenode.app.config", "files/app.config"}. +{file, "simplenode.sys.config", "files/sys.config"}. {template, "simplenode.vm.args", "files/vm.args"}. {template, "simplenode.windows.runner.cmd", "files/{{nodeid}}.cmd"}. {file, "simplenode.windows.start_erl.cmd", "files/start_erl.cmd"}. diff --git a/priv/templates/simplenode.windows.start_erl.cmd b/priv/templates/simplenode.windows.start_erl.cmd index b26e98a..f98c285 100644 --- a/priv/templates/simplenode.windows.start_erl.cmd +++ b/priv/templates/simplenode.windows.start_erl.cmd @@ -19,8 +19,18 @@ @set erl_exe=%node_root%\erts-%erts_version%\bin\erl.exe @set boot_file=%releases_dir%\%release_version%\%node_name% -@set app_config=%node_root%\etc\app.config -@set vm_args=%node_root%\etc\vm.args + +@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% -- cgit v1.1