Reputation: 43
I'm trying to use an MQTT library in elixir known as Tortoise. Whenever I use iex -S mix
I can get the sending of messages to work. However when I use mix start
to begin my start task the program will not work. I'm get an unknown registry: Tortoise.Registry
error.
I can start the supervisor for Tortoise without error, it is when I try starting a child process for that process with Tortoise.Supervisor.start_child
that I get the error.
defmodule Mqtt.Begin do
require Tortoise
def start do
opts = [strategy: :one_for_one, name: Mqtt.Begin]
{:ok, pid} = Tortoise.Supervisor.start_link(opts)
{:ok, _} =
Tortoise.Supervisor.start_child(Mqtt.Begin, [
client_id: :a,
handler: {Mqtt.Handler, [name: :a]},
server: {Tortoise.Transport.Tcp, host: 'localhost', port: 1883},
subscriptions: [{"share/share-group/bar", 0}] ])
When using extern libraries in elixir is the entire library created with deps.compile? Or do I need to do something further?
Upvotes: 0
Views: 170
Reputation: 622
Seems that this is because of erlang code loading principals
When you start your application using iex -S mix
erlang starts it into interactive mode
and automatically loads all modules.
mix start
(you should call mix run
) seems to start your application in embedded mode
In embedded mode, code is loaded at start-up according to a boot script.
http://erlang.org/doc/reference_manual/code_loading.html#code-loading
To make it work you have to add :tortoise
into your application
list in mix.exs
:
def application do
[
extra_applications: [:logger, :ssl, :tortoise],
mod: {Your.App, []}
]
end
Upvotes: 1