简体   繁体   中英

How to start deps application automatcially in Chicago Boss?

I can't figure out how to automatically start an "deps" applciation in Chicago Boss.

Use applcation:which_applications() I can see a bunch started like "lager, ranch, cowboy ..etc etc". How do I start another one I added?

If I go to console and run application:start(oauth2) and it's ok. I can start it.

But I tried to change src/xxx.app.src and add it to {applications,[]} , but no go. Isn't this the place to load/start any application that mine depends on?

But I can't find how boss loads and start all the other applications either.

By the way, this oauth2 appliation doesn't contain an application-behavior file (oauth2_app.erl) so I don't know if this is related. Since I can manually start it ok.

So, confused. Any help would be appreciated.

Plus: I remember that I did start application by adding the application:start(xxx) into the /priv/init/xxx_01_news.erl init function but that's very hackish I think.

You can use rebar.config to add your dependency applications then edit boss.config file this way:

  • First: Add the dependency applications name in applications .
  • Second: Add their specific configurations as follows.

boss.config file:

[
   {boss, [
      {path, "./deps/boss"},
      {applications, [your_app_name, your_app_dep_1, your_app_dep_2]},
      {assume_locale, "en"},

%% ... other configuration

%% APPLICATION CONFIGURATIONS
   {your_app_name, []},
   {your_app_dep_1, []},
   {your_app_dep_2, []}                                                                                                                                                                  
].                  

Edit: This way CB expects another boss application so looks for the router file and warns if cannot find it. However starting the dependencies inside its init function is not a dirty way and I suggest to consider it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM