aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Frengstad <[email protected]>2013-06-20 09:53:23 +0200
committerOlav Frengstad <[email protected]>2013-06-20 10:04:53 +0200
commit5ed7ea3172170fa05ac806250f695834d5d6ae58 (patch)
tree0247674887803bb006fb2384c0bc4e98e4371e04
parentc5f0a8c9175b2d152c69f72da15e7ceff411f86b (diff)
downloadrelx-5ed7ea3172170fa05ac806250f695834d5d6ae58.tar.gz
relx-5ed7ea3172170fa05ac806250f695834d5d6ae58.tar.bz2
relx-5ed7ea3172170fa05ac806250f695834d5d6ae58.zip
Add support for {vm_args,_} argument in config
-rw-r--r--examples/relcool.config3
-rw-r--r--src/rlx_prv_assembler.erl21
-rw-r--r--src/rlx_prv_config.erl2
-rw-r--r--src/rlx_prv_overlay.erl1
-rw-r--r--src/rlx_state.erl11
5 files changed, 37 insertions, 1 deletions
diff --git a/examples/relcool.config b/examples/relcool.config
index b5b02fc..77d7acf 100644
--- a/examples/relcool.config
+++ b/examples/relcool.config
@@ -24,6 +24,9 @@
%% directory it will be automatically added.
{paths, ["/opt/erlang_apps"]}.
+%% If needed you can use a specific vm.args file instead of the
+%% one automatically generated by relx.
+{vm_args, "./config/vm.args"}.
%% If you have a sys.config file you need to tell relcool where it is. If you do
%% that relcool will include the sys.config in the appropriate place
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index 18a372c..20f9c5c 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -250,9 +250,28 @@ write_bin_file(State, Release, OutputDir, RelDir) ->
ok = file:write_file(BareRel, StartFile),
ok = file:change_mode(BareRel, 8#777)
end,
- ok = file:write_file(filename:join(RelDir, "vm.args"), vm_args_file(RelName)),
+ copy_or_generate_vmargs_file(State, RelName, RelDir),
copy_or_generate_sys_config_file(State, Release, OutputDir, RelDir).
+%% @doc copy vm.args or generate one to releases/VSN/vm.args
+-spec copy_or_generate_vmargs_file(rlx_state:t(), string(), file:name()) ->
+ {ok, rlx_state:t()} | relx:error().
+
+copy_or_generate_vmargs_file(State, RelName, RelDir) ->
+ RelVmargsPath = filename:join([RelDir, "vm.args"]),
+
+ case rlx_state:vm_args(State) of
+ undefined ->
+ ok = file:write_file(RelVmargsPath, vm_args_file(RelName));
+ ArgsPath ->
+ case filelib:is_regular(ArgsPath) of
+ false ->
+ ?RLX_ERROR({vmargs_does_not_exist, ArgsPath});
+ true ->
+ ec_file:copy(ArgsPath, RelVmargsPath)
+ end
+ end.
+
%% @doc copy config/sys.config or generate one to releases/VSN/sys.config
-spec copy_or_generate_sys_config_file(rlx_state:t(), rlx_release:t(),
file:name(), file:name()) ->
diff --git a/src/rlx_prv_config.erl b/src/rlx_prv_config.erl
index 36a0527..bbdf6e6 100644
--- a/src/rlx_prv_config.erl
+++ b/src/rlx_prv_config.erl
@@ -165,6 +165,8 @@ load_terms({release, {RelName, Vsn}, {erts, ErtsVsn},
{ok, Release1} ->
{ok, rlx_state:add_configured_release(State, Release1)}
end;
+load_terms({vm_args, VmArgs}, {ok, State}) ->
+ {ok, rcl_state:vm_args(State, filename:absname(VmArgs))};
load_terms({sys_config, SysConfig}, {ok, State}) ->
{ok, rlx_state:sys_config(State, filename:absname(SysConfig))};
load_terms({Name, Value}, {ok, State})
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index 5fffd78..2a81730 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -200,6 +200,7 @@ generate_state_vars(State) ->
{lib_dirs, rlx_state:lib_dirs(State)},
{config_file, rlx_state:config_file(State)},
{providers, rlx_state:providers(State)},
+ {vm_args, rlx_state:vm_args(State)},
{sys_config, rlx_state:sys_config(State)},
{root_dir, rlx_state:root_dir(State)},
{default_release_name, case rlx_state:default_configured_release(State) of
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 9b0811f..f5f363e 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -37,6 +37,8 @@
config_file/2,
providers/1,
providers/2,
+ vm_args/1,
+ vm_args/2,
sys_config/1,
sys_config/2,
root_dir/1,
@@ -78,6 +80,7 @@
providers = [] :: [rlx_provider:t()],
available_apps = [] :: [rlx_app_info:t()],
default_configured_release :: {rlx_release:name(), rlx_release:vsn()},
+ vm_args :: file:filename() | undefined,
sys_config :: file:filename() | undefined,
overrides :: [{AppName::atom(), Directory::file:filename()}],
skip_apps = [] :: [AppName::atom()],
@@ -183,6 +186,14 @@ config_file(State, ConfigFiles) ->
providers(#state_t{providers=Providers}) ->
Providers.
+-spec vm_args(t()) -> file:filename() | undefined.
+vm_args(#state_t{vm_args=VmArgs}) ->
+ VmArgs.
+
+-spec vm_args(t(), file:filename()) -> t().
+vm_args(State, VmArgs) ->
+ State#state_t{vm_args=VmArgs}.
+
-spec sys_config(t()) -> file:filename() | undefined.
sys_config(#state_t{sys_config=SysConfig}) ->
SysConfig.