[erlang-questions] Deployment rebar3

Stefan Hellkvist hellkvist@REDACTED
Mon May 7 16:03:45 CEST 2018


What's "best" is very much depending on who you ask, but, for starters you
may consider wrapping your configuration with something that allows you to
override config variables with environment variables (see example below).
This would make it easier to run things without changing files and it would
also prepare you for whenever you enter docker-/kube-land later
also...should you decide to take that step.

/Stefan




...an example

-module(config).

-export([get/1]).

%% reads a configuration value Key. Values are placed in sys.config as atoms
%% but can be overridden by setting environment variables in the os. The
environment
%% variable name is given by the atom name converted to a string/list and
then uppercased
%% example: my_atom_key would translate to the environment variable
MY_ATOM_KEY
get(Key) when is_atom(Key) ->
    {ok, Default} = application:get_env(axon, Key),
    EnvName = string:to_upper(atom_to_list(Key)),
    case os:getenv(EnvName) of
        false ->
            Default; %% assume it has the right type in config

        OSVal ->
            convert(OSVal, Default)
    end.

convert(Val, Default) when is_list(Val), is_integer(Default) ->
    list_to_integer(Val);
convert(Val, Default) when is_list(Val), is_binary(Default) ->
    list_to_binary(Val);
convert(Val, Default) when is_list(Val), is_boolean(Default) ->
    list_to_atom(Val);
convert(Val, Default) when is_list(Val), is_list(Default) ->
    Val.

On Mon, May 7, 2018 at 3:45 PM, asdf asdf <codewiget95@REDACTED> wrote:

> Hey everyone,
>
> I’ve recently built a few applications that handle high volume message
> passing and all communicate with each other using Erlang’s ssl
> distribution. I’m working on deploying these to multiple servers - right
> now I am just using rebar3 release and creating a zipped tar of the release
> directory, moving it to a new box, and changing the some vm.args and
> sys.config options on the new machines. This doesn’t seem totally intuitive
> though… it take far longer than I feel like it should.
>
> I’ve read about Docker and Kubernetes, and those seem promising, but our
> IT guys aren’t ready to move to containers and are using static nodes right
> now.
>
> So, what is the best way to quickly distribute your erlang binaries and
> configure the enviornment? Have a quick script to do it automatically? Is
> the answer just containerize with Docker and wait a few months for the IT
> team to catch up with it? Or is there some other option out there?
>
> Thanks for your help!
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180507/8370b554/attachment.htm>


More information about the erlang-questions mailing list