Created
December 8, 2018 21:53
-
-
Save RichMorin/6fca3429b0e3754d21b92e11f6818559 to your computer and use it in GitHub Desktop.
Re: non-working Agent reload code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tracing RefData.Server.start_link/0, I found that it isn't getting run | |
after the exit. So, I probably have a problem in the Supervision setup. | |
I will look into this, but meanwhile, here is my current setup: | |
========================================================= | |
defmodule PhxHttp.Application do | |
# See https://hexdocs.pm/elixir/Application.html | |
# for more information on OTP Applications | |
@moduledoc false | |
use Application | |
def start(_type, _args) do | |
# List all child processes to be supervised | |
children = [ | |
# Start the endpoint when the application starts | |
PhxHttpWeb.Endpoint | |
# Starts a worker by calling: PhxHttp.Worker.start_link(arg) | |
# {PhxHttp.Worker, arg}, | |
] | |
# See https://hexdocs.pm/elixir/Supervisor.html | |
# for other strategies and supported options | |
opts = [strategy: :one_for_one, name: PhxHttp.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 | |
PhxHttpWeb.Endpoint.config_change(changed, removed) | |
:ok | |
end | |
end | |
========================================================= | |
defmodule RefData.Application do | |
use Application | |
@doc """ | |
Load the TOML file tree, then fold in the index. | |
""" | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
children = [ | |
worker(RefData.Server, []), | |
] | |
options = [ | |
name: RefData.Supervisor, | |
strategy: :one_for_one, | |
] | |
Supervisor.start_link(children, options) | |
end | |
end | |
========================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While it's a valid strategy to have two different applications to separate these concerns, go ahead and just use one Application for now and treat your
RefData.Server
as a kind of library:I've added a
child_spec
so that you can explicitly have an ID forRefData.Server
, which is necessary to look it up in the supervisor. An ID can actually be any valid atom (or maybe even any valid term). Check out the documentation for Supervisor for more information on that.Now at this point, you should be able to call this:
without any problems