natewallis

natewallis

Worker registered name not showing in observer

Hi..

I am registering two workers for my application supervision tree:

defmodule SamlyHowto.Application do
  use Application

  # See https://hexdocs.pm/elixir/Application.html
  # for more information on OTP Applications
  def start(_type, _args) do
    import Supervisor.Spec

    # Define workers and child supervisors to be supervised
    children = [
      # Start the endpoint when the application starts
      supervisor(SamlyHowtoWeb.Endpoint, []),
      # Start your own worker by calling: SamlyHowto.Worker.start_link(arg1, arg2, arg3)
      # worker(SamlyHowto.Worker, [arg1, arg2, arg3]),
      worker(Samly.Provider, [], [id: Fed1]),
      worker(Samly.Provider, [], [id: Fed2]),
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: SamlyHowto.Supervisor]
    Supervisor.start_link(children, opts)
  end

  # Tell Phoenix to update the endpoint configuration
  # whenever the application is updated.
  def config_change(changed, _new, removed) do
    SamlyHowtoWeb.Endpoint.config_change(changed, removed)
    :ok
  end
end

Samly.Provider defines their start_link function like this:

def start_link(gs_opts \\ []) do
    GenServer.start_link(__MODULE__, [], gs_opts)
end

As per the docs, I thought they should have been named Fed1 and Fed2… I have also tried the following (adding name):

  worker(Samly.Provider, [], [id: Fed1, name: Fed1]),
  worker(Samly.Provider, [], [id: Fed2, name: Fed2])

The examples on this page suggests that “name” should do the job:

But here there is no mention of “name” being an option here:

When I run observer.start() the registered name doesn’t appear (however I can see the numbered processes) there OR even when I run Process.registered() from IEX there is no mention of the name, but the app launches ok..

[:cowboy_clock, :erl_prim_loader, SamlyHowto.PubSub.Supervisor,
 :ssl_connection_sup, Logger.WatcherSupervisor, :user_drv,
 SamlyHowtoWeb.Endpoint.LongPoll.Supervisor, :ssl_admin_sup,
 SamlyHowtoWeb.Endpoint.Server, :ssl_sup, SamlyHowtoWeb.Endpoint.Config,
 :httpd_sup, :pg2, :phoenix_live_reload_file_monitor, :elixir_config,
 SamlyHowto.PubSub, :elixir_code_server, Hex.Supervisor, :ssl_pem_cache,
 :hex_fetcher, :ssl_manager, SamlyHowtoWeb.Endpoint, :inet_db,
 :ssl_listen_tracker_sup, Hex.Registry.Server, :kernel_safe_sup, Hex.State,
 :runtime_tools_sup, :global_group, :rex, :httpc_sup, :httpc_hex, :kernel_sup,
 IEx.Supervisor, :global_name_server, :dtls_udp_sup, :httpc_profile_sup,
 SamlyHowto.Supervisor, :httpc_manager, :file_server_2, :dtls_connection_sup,
 :httpc_handler_sup, :ftp_sup, Phoenix.Supervisor, :esaml_ets_table_owner,
 :tls_connection_sup, Gettext.ExtractorAgent, :standard_error, :inets_sup,
 Mix.ProjectStack, ...]

What I am doing wrong?

Thanks,
Nathan

Marked As Solved

natewallis

natewallis

Here to answer my own question… just got mixed up with arguments and opts with the worker/3() call..

children = [
  # Start the endpoint when the application starts
  supervisor(SamlyHowtoWeb.Endpoint, []),
  # Start your own worker by calling: SamlyHowto.Worker.start_link(arg1, arg2, arg3)
  # worker(SamlyHowto.Worker, [arg1, arg2, arg3]),
  worker(Samly.Provider, [[name: Fed1]], [id: Fed1]),
  worker(Samly.Provider, [[name: Fed2]], [id: Fed2]),
]

Also Liked

amarandon

amarandon

I’m wondering how to achieve this with child spec, which replaces the deprecated Supervisor.Spec module. I’d like my process passed to a supervisor as a child spec to appear with a nice human readable name in the observer “Applications” tab rather than just seeing a pid.

vans163

vans163

Ditto Ditto

Where Next?

Popular in Questions Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement