Closed ghost closed 5 years ago
It looks to me like your repo wasn't added to any supervision tree.
It does look like that is missing from the Readme. I'll add it tomorrow.
You should havea file called application.ex
with a list of children
. You will need to add Tui.Database
to that list.
Thx for your quick answer!
Yes, I'm an newcomer to Elixir :-)
Well, here is my application.ex
:
defmodule TUI.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = [
{
Plug.Cowboy,
name: WebServer.Supervisor,
scheme: :http,
plug: TUI.Router,
options: [ port: Application.get_env(:tui, :port) ]
},
{
TUI.Database,
name: Database.Supervisor
}
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
I suggest putting the TUI.Database
before the webserver, and remove the name
option.
defmodule TUI.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = [
TUI.Database,
{
Plug.Cowboy,
name: WebServer.Supervisor,
scheme: :http,
plug: TUI.Router,
options: [ port: Application.get_env(:tui, :port) ]
}
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
It worked! Thx!
I'm kind of puzzled that it did not work otherwise... I'm probably missing a lot there.
The children are supposed to be independent, isn't ?
Why the name would have any influence there? Should the config files and other places to be updated accordingly for the name
option to work?
Anyway, thank you! :+1:
TUI.Database.insert(%TUI.Database.Tests{name: "jazzyb"})
20:36:26.235 [debug] QUERY OK db=22.9ms queue=0.1ms
INSERT INTO "tests" ("name","inserted_at","updated_at") VALUES (?1,?2,?3) ;--RETURNING ON INSERT "tests","id" ["jazzyb", {{2018, 11, 28}, {19, 36, 26, 212121}}, {{2018, 11, 28}, {19, 36, 26, 212150}}]
{:ok,
%TUI.Database.Tests{
__meta__: #Ecto.Schema.Metadata<:loaded, "tests">,
id: 1,
inserted_at: ~N[2018-11-28 19:36:26.212121],
name: "jazzyb",
updated_at: ~N[2018-11-28 19:36:26.212150]
}}
Hi!
I tried to follow the tutorial but got stuck:
What could be wrong?
Thx!