Compilation error - no process

Hello!

I have umbrella project and one of its application (Phoenix) does not compile:

my_app_umbrella$ mix compile
==> my_app_web
Compiling 25 files (.ex)

== Compilation error in file lib/my_app_web/controllers/about_controller.ex ==
** (exit) exited in: GenServer.call(MyAppWeb.Page, {:get_info, "about"}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir) lib/gen_server.ex:766: GenServer.call/3
    lib/my_app_web/controllers/about_controller.ex:6: (module)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

I starting GenServer during application start:

defmodule MyAppWeb.Application do
  use Application

  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(MyAppWeb.Endpoint, []),
      # Start your own worker by calling: MyAppWeb.Worker.start_link(arg1, arg2, arg3)
      # worker(MyAppWeb.Worker, [arg1, arg2, arg3]),
      worker(MyAppWeb.Page, []),
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: MyAppWeb.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
    MyAppWeb.Endpoint.config_change(changed, removed)
    :ok
  end
end

I am using MyAppWeb.Page GenServer to return page information to controller:

defmodule MyAppWeb.HomeController do
  use MyAppWeb, :controller

  alias MyAppWeb.Page

  @page Page.get_info("home")

  def index(conn, _params) do
    render conn, "index.html", page: @page
  end
end

Same approach works fine in regular Phoenix application (not umbrella).

I wonder if I missed some configuration in umbrella project.

You are calling Page.get_info("home") already during compile time. I assume that function is calling the GenServer which is not running at compile time.

Module attributes are evaluated at compile time. You may need to change @page to a private function for example.

Works fine now.
Thank you very much! :tada: