codecakes
I have an app like
stackdelivery
├── lib
└── stackdelivery
└── application.ex
└── stackgen
└── stackgen.ex
└── supervisor.ex
stackdelivery.ex
mix.exs
application.ex is
defmodule Stackdelivery.Application do
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
use Supervisor
def start(_type, _args) do
import Supervisor.Spec, warn: true
# Define workers and child supervisors to be supervised
children = [
supervisor(Stackdelivery.StackGen.Supervisor, [])
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Stackdelivery.StackAppSupervisor]
Supervisor.start_link(children, opts)
end
end
supervisor.ex is
defmodule Stackdelivery.StackGen.Supervisor do
@moduledoc """
Supervisor for StackGen module
"""
use Supervisor
alias Stackdelivery.Stack
def start_link do
Supervisor.start_link(__MODULE__, [], name: __MODULE__)
end
def init(_) do
IO.puts "starting StackGen.Supervisor supervisor.."
children = [
worker(Stack, [])
]
opts = [strategy: :simple_one_for_one, name: Stackdelivery.StackGenSupervisor]
supervise(children, opts)
end
def shoot, do: Supervisor.start_child(__MODULE__, [])
end
stackgen is a simple Stacn Genserver. for brevity:
defmodule Stackdelivery.Stack do
use GenServer
def init(_) do
IO.puts "Starting a New GenServer Stack"
{:ok, []}
end
....
I can’t start multiple child processes using Stackdelivery.StackGen.Supervisor.shoot
The way I am thinking is how supervision tree should be is:
Application (Main Supervisor)
└── StackGen.Supervisor (Module Supervisor)
└── Stackgen (GenServer)
Now when Application.start_link happens, how can we invoke child proceses in StackGen.Supervisor for Stackgen workers?
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
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
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
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
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 9 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
codecakes
idk, its not working for me
works when
wont work when
Supervisor.start_link(__MODULE__, [], name: @name)voughtdq
OK. I have a working example now. Sorry to have misled you with incorrect information. I hope this makes up for it
Some notes:
use Supervisorin application.ex ultimately caused the problem since they likely conflict with each other. I didn’t catch that at first.Elxir! (i.e.Elixir.StackDelivery.StackGen.Supervisor), so I’m not sure if that came into play or notNonetheless, I’ve tested this and it seems to be working fine.
application.ex
stack_gen_supervisor.ex
stack_gen.ex
mix.exs
codecakes
in
worker(module, args, options \\ [])id can be
__MODULE__right?codecakes
can you give me an example with a code snippet?
voughtdq
In my app, I’m not using
:simple_one_for_onestrategy. Each GenServer I start has a unique id - that’s why the example I gave you has aunique_idargument.codecakes
should each time the id be unique?
voughtdq
You’re right. My code doesn’t use
:simple_one_for_one. The app I took the example code from uses a:one_for_one.I’ll play with your code and see if I can find out what’s going on.
codecakes
isnt transient is default for simple_one_for_one?
Is this unique name unique everytime each pid starts?
voughtdq
Supervisor.start_child/2needs a spec! See Supervisor.SpecAlso, I think it has to have an
idif you’re starting multiple GenServers of the same module.