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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #elixirconf-us
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










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.