23 lines
476 B
Elixir

defmodule MessageServer.Application do
use Application
require Logger
@impl true
def start(_type, _args) do
server_id = get_server_id()
children = [
{MessageServer.Storage, server_id}
]
opts = [strategy: :one_for_one, name: MessageServer.Supervisor]
Supervisor.start_link(children, opts)
end
@spec get_server_id() :: String.t()
def get_server_id() do
System.get_env("SERVER_ID") ||
raise "SERVER_ID is required"
end
end