Use Bandit child spec directly
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user