leifericf
I’ve noticed that, in certain cases, the order in which applications start is significant.
Example from page 200 from Adopting Elixir:
It is also important to guarantee the
:saslapplication is started before the:loggerapplication. Otherwise you will get duplicate reports.Your
mix.exsshould look like this:
extra_applications: [:sasl, :logger]
In such cases, the programmer must ensure that applications are started in the correct order.
Perhaps it would be possible implement an improvement, such that applications are automatically started in the correct order? To make this work, I suppose each application would need to declare its own “startup dependencies” and/or “startup importance level.”
This would effectively move the responsibility of starting applications in the correct order from the programmer who uses the application, to the programmer who develops said application.
I don’t know whether this is doable; it’s just a thought that struck me whilst reading.
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
You might be interested in Included Applications — Erlang System Documentation v29.0.2.
leifericf
@idi527 - Thanks for the link!
As far as I can tell, the same challenge exists in Erlang as well:
That is, the programmer is responsible for starting the applications in the correct order, by placing them in the correct order in the
.app-file (under theincluded_applications key-key).Perhaps this could be automated somehow by Elixir?
michalmuskala
AFAIK the
saslis no longer an issue in OTP 21, since the logs are now produced by the erlang’s new:loggerthat is always started.saslis now only what it was always supposed to be - just tooling for releases.idi527
Each library we use in elixir and erlang is itself an app, so the app files can be written by the library author.
leifericf
Thanks for the info! That’s good to know.
Are you aware of any other cases where the order in which the applications are included is significant, or was this just an odd exception case when using
saslin combination withlogger?rupurt
@leifericf I’m running into a similar problem trying to send
vmstatsinformation tostatsdviastatix. I need to ensure thatstatixhas connected to thestatsdserver before thevmstatsapplication has started. The solution I came up with was to set thevmstatsdependency toruntime: falseand manually start it in my main application.It would be fantastic if there was some way to specify the order in
mix.exswithout clobbering all applications by adding theapplicationskey todef applicationsleifericf
I thought I had misunderstood something and made a fool of myself by posting this thread, so I’m glad to hear that somebody else might be having a related issue to vindicate me
I’m too much of a newbie to be able to provide advice for your specific situation, @rupurt, but I’m sure one of our forum friends of greater clout will swing by and knock it out the the park.
sasajuric
The problem with this approach is that the application is not included in the application list, even though it’s required at runtime. This means you can’t build a proper OTP release with distillery (I’m presuming you’re not doing it now, but might want to do in the future). Any other tool which relies on the application list will also not work properly.
Instead of using
runtime: false, you could instead add thevmstatsapplication to theincluded_applicationslist:And then somewhere in the supervision tree include
%{id: :vmstats, start: {:vmstats, :start, [:normal, []]}}as a child. This will work properly with distillery, since application will be included in the release, but it won’t be started when the release is booted. Instead, the app is started in your own supervision tree.Alternatively you could use
vmstatsnormally (i.e. dropincluded_applicationsandruntime: false). In your app startup callback you could invoke something likeApplication.put_env(your_app, :statix_connected?, true)immediately after invokingStatix.connect, and then in your sink callback function push the data only ifApplication.get_env(your_app, :statix_connected?) == true.rupurt
@sasajuric thanks for the detailed insight. You’re correct, I’m not deploying my app yet but did plan on using distillery for an OTP release so this has saved me a wall of head bashing in the future
Both approaches sound interesting and I can actually see me needing better error handling in the sink for when the statsd server is down etc… so I’ll probably go with that approach.
Cheers!