Use Bandit child spec directly

This commit is contained in:
2026-06-21 14:26:04 +02:00
parent a89175e230
commit 64ca5d4637
2 changed files with 12 additions and 24 deletions

View File

@@ -41,6 +41,7 @@ after each item.
- [x] `ui/registry.ex` O(1) lookups (verified keep: compile-time caching would freeze localized labels)
- [x] `bounded_atoms.ex` O(1) allow-lists
- [x] `scripting/job_store.ex`
- [x] `desktop/server.ex`
---

View File

@@ -1,17 +1,18 @@
defmodule BDS.Desktop.Server do
@moduledoc false
use GenServer
def child_spec(opts) do
%{
id: __MODULE__,
start: {__MODULE__, :start_link, [opts]}
}
end
def start_link(opts) do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
Supervisor.child_spec(
{Bandit,
Keyword.merge(opts,
plug: BDS.Desktop.Endpoint,
scheme: :http,
ip: {127, 0, 0, 1},
port: port(),
startup_log: false
)},
id: __MODULE__
)
end
def url do
@@ -24,18 +25,4 @@ defmodule BDS.Desktop.Server do
_other -> Application.get_env(:bds, :desktop)[:port] || 4010
end
end
@impl true
def init(_opts) do
{:ok, bandit_pid} =
Bandit.start_link(
plug: BDS.Desktop.Endpoint,
scheme: :http,
ip: {127, 0, 0, 1},
port: port(),
startup_log: false
)
{:ok, %{bandit_pid: bandit_pid}}
end
end