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
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’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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
Other Trending Topics
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
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
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
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
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 7 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
vinibrl
For those who might run into this problem, in my case it was a typo in the module name.
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).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.
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.
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
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
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?