0

I am looking to add Kinetic to my chicago boss app, I have added the kinetic library to the deps directory within my chicago boss app. When I run the erlang shell from within the kinetic directory I have a development.config in the root of the kinetic directory that looks like the below:

[{kinetic,
    [{args, [
        % All of these values are optional
        % kinetic will get all of the context from the instance
        {region, "us-east-1"},
        {aws_access_key_id, "AKAAAAAABABABA"},
        {aws_secret_access_key, "3/Fx9987sxc352728181892838bhbjkd"},
        {iam_role, "kinetic"},

        {lhttpc_opts, [{max_connections, 5000}]}
    ]}]
}].

when I start the chicago boss app and run a kinetic command Im getting an invalid credentials error so it seems the kinetic library loaded properly but not the constants for my aws keys...Any idea how to do this in chicago boss?

Thanks!

BC00
  • 1,589
  • 3
  • 29
  • 47

1 Answers1

1

Solution

Just paste your tuple {kinetic, [...]} from development.config to boss.config which contains list of configurations for your erlang applications.

More general about configuration files

In each application which depends on configuration we can see code like application:get_env(App, Key) or application:get_env(App, Key, SomeDefault). It's in fact call to application_controller which briefly manages application loading/unloading/starting/stoping and keeps informations about it. You can check how much it knows with io:format("~n~p~n",[ets:tab2list(ac_tab)]). These are mostly taken from .app files in ebin/ directory which are mostly generated by rebar from app.src in src/ during compilation.

The most interesting key for us in .app.src is env which should contain default configuration for application which will be loaded as first and then some of those values will be overridden by your system config which is now boss.config.

When you were playing with kinetic in it's development environment you were starting it by erl -pa ebin -pa deps/*/ebin -s inets -s crypto -s ssl -s lhttpc -config development -s kinetic with -config you passed your system config and overridde default environment values which in this case are not specified and defaults are resolved after application is started in kinetic_config.erl but look at lager.app.src and compare it to one within your boss.config. Now you see how to tweak it. Let's start with colouring logs ;)

From official documentation: Configuring an Application and config

Łukasz Ptaszyński
  • 1,639
  • 1
  • 12
  • 11
  • Hey Łukasz thanks so much for helping me with all these questions, I pasted my tuple into the boss.config but am still getting the same {error,missing_credentials} response. Is there any way I can debug this? – BC00 Dec 06 '14 at 16:31
  • @BC00 No problem, can you check `ets:lookup(kinetic_data, args).` and `application:get_all_env(kinetic).`? – Łukasz Ptaszyński Dec 06 '14 at 16:42
  • @BC00 i guess there is something wrong with correct starting of applications. Don't forget to add `kinetic` to `applications` list in `src/your_boss.app.src` and then `rebar compile`. Check if it's ruuning with `application:which_applications()` and if it's not, force it with `application:ensure_all_started(your_boss_app or kinetic)`. – Łukasz Ptaszyński Dec 06 '14 at 18:13
  • hmm it seems the application:ensure_all_started(kinetic). worked – BC00 Dec 06 '14 at 18:52
  • its just weird that I was getting {error,missing_credentials} because it mustve had the kinetic code loaded right? the error i get now is ** exception error: undefined function jiffy:encode/1 in function kinetic_utils:encode/1 (src/kinetic_utils.erl, line 42) in call from kinetic:execute/3 (src/kinetic.erl, line 196) – BC00 Dec 06 '14 at 18:53
  • That kinetic is bugged... there is no jiffy dependency in kinetic.app.src. previously you ran erl with -pa deps/*/ebin/ so it was loaded now it tries to resolve it with those dependencies. Try to add that jiffy before kinetic or to kinetic.app.src. Loaded modules doesn't mean loaded and started application. – Łukasz Ptaszyński Dec 06 '14 at 19:01
  • @BC00 Forgot to call you. Add all those dependencies: lhttpc, jiffy, meck to deps/kinetic/src/kinetic.app.src . – Łukasz Ptaszyński Dec 06 '14 at 19:14
  • {application, kinetic, [ {description, "Erlang Kinesis Client"}, {vsn, "1"}, {modules, []}, {registered, [kinetic_config]}, {applications, [kernel, stdlib, inets, crypto, ssl, lhttpc, jiffy, meck]}, {env, []}, {mod, {kinetic,[]}} ]}. – BC00 Dec 06 '14 at 19:33
  • Should work. Try to compile and check if it works. Is jiffy loaded now? – Łukasz Ptaszyński Dec 06 '14 at 19:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66330/discussion-between-bc00-and-lukasz-ptaszynski). – BC00 Dec 06 '14 at 19:47
  • @BC00 Hello, i tried to find a way for proper way of starting external applications but according to this [CB issue](https://github.com/ChicagoBoss/ChicagoBoss/issues/75) there is none. I added few lines and opened [pull request](https://github.com/ChicagoBoss/ChicagoBoss/pull/530). It works for me. Basically... CB is not an proper OTP app nor release - it's based on scripts. – Łukasz Ptaszyński Dec 07 '14 at 19:26