AlanMcCann
I’m having trouble getting Supervisor.start_child to work and I get the following error when running these commands (the supervisor is started automatically. Any help is appreciated. I’m likely missing something simple.
import Supervisor.Spec
sup_pid = sup_pid = Process.whereis(App.SessionSupervisor)
Supervisor.start_child(sup_pid,["a"])
{:error,
{:EXIT,
{:undef,
[{App.Session, :start_link, [["a"]], []},
{:supervisor, :do_start_child_i, 3, [file: 'supervisor.erl', line: 374]},
{:supervisor, :handle_call, 3, [file: 'supervisor.erl', line: 399]},
{:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 629]},
{:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 661]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}}
session_supervisor.ex
defmodule App.SessionSupervisor do
use Supervisor
def start_link do
Supervisor.start_link(__MODULE__, :ok, name: App.SessionSupervisor)
end
def init(:ok) do
children = [worker(App.Session, [], restart: :transient)]
worker(App.Session, [], restart: :transient)
supervise(children, strategy: :simple_one_for_one)
end
end
session.ex
defmodule App.Session do
use GenServer
@doc """
Starts a new session.
"""
def start_link(uuid, opts \\ []) do
GenServer.start_link(__MODULE__, %{uuid: uuid})
end
… rest of the code.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
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
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
scouten
Hi Alan, bumped into this just a few hours ago myself. The docs on this are terrible at telling you what you should provide. (Thankfully, that is a rarity!)
In my case, I had printed a
start_link/1function, but I needed to provide astart_link/2function. Took me a while to get that right.In your code, in see three different models name prefixes: App, Jaeger, and Jeager. Perhaps this is as simple as a typo?
AlanMcCann
Thanks for the reply.
The different models were just failed attempts at obfuscating/generalizing the code after initially pasting it in. They are now changed to all be App. I went back and double checked all of the code and it isn’t a typo.
I thought I had a start_link/2 function but perhaps I’m missing something in the proper parameters
NobbZ
Are you sure that
App.Sessionis compiled AND loaded?_build/$MIX_ENV-folder and search for a file namedElixir.App.Session.beam, if it is not there than your code doesn’t get compiled.AlanMcCann
@Nobbz: Thanks for the debugging tip… that was new learning for me.
the file is there and I’m able to start the session Genserver from iex -S mix
Running :observer.start I can see Elixir.App.Supervisor → Elixir.App.SessionSupervisor. I don’t know if it is possible to inspect models from :observer.
AlanMcCann
Fix found - formatting the params for start_link as
vs
allows it to properly started a linked child process
Thanks @NobbZ and @scouten for offering good pointers.
aharpole
Because there are a lot of
start_linkfunctions in this example, I thought I’d mention that you wantstart_link/2in the GenServer supervised by your DynamicSupervisor (App.Sessionin the above example).vinibrl
For those who might run into this problem, in my case it was a typo in the module name.