mix phx.server working
This commit is contained in:
parent
0f1131b406
commit
840cbe251c
35
main.ex
35
main.ex
|
@ -1,19 +1,3 @@
|
||||||
# config
|
|
||||||
counter = :counters.new(1, [])
|
|
||||||
|
|
||||||
Application.put_env(:sfe, Sfe.Endpoint,
|
|
||||||
http: [ip: {127, 0, 0, 1}, port: 5001],
|
|
||||||
pubsub_server: Sfe.PubSub,
|
|
||||||
adapter: Bandit.PhoenixAdapter,
|
|
||||||
debug_errors: true,
|
|
||||||
code_reloader: true,
|
|
||||||
server: true,
|
|
||||||
live_view: [signing_salt: "aaaaaaaa"],
|
|
||||||
secret_key_base: String.duplicate("a", 64)
|
|
||||||
)
|
|
||||||
|
|
||||||
Application.put_env(:sfe, Sfe.HomeLive, counter_ref: counter)
|
|
||||||
|
|
||||||
# application
|
# application
|
||||||
defmodule Sfe do
|
defmodule Sfe do
|
||||||
defmodule Application do
|
defmodule Application do
|
||||||
|
@ -24,6 +8,23 @@ defmodule Sfe do
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
Logger.debug("Sfe starting...")
|
Logger.debug("Sfe starting...")
|
||||||
|
|
||||||
|
# config
|
||||||
|
counter = :counters.new(1, [])
|
||||||
|
dbg(counter)
|
||||||
|
|
||||||
|
Elixir.Application.put_env(:sfe, Sfe.Endpoint,
|
||||||
|
http: [ip: {127, 0, 0, 1}, port: 5001],
|
||||||
|
pubsub_server: Sfe.PubSub,
|
||||||
|
adapter: Bandit.PhoenixAdapter,
|
||||||
|
debug_errors: true,
|
||||||
|
code_reloader: true,
|
||||||
|
server: true,
|
||||||
|
live_view: [signing_salt: "aaaaaaaa"],
|
||||||
|
secret_key_base: String.duplicate("a", 64)
|
||||||
|
)
|
||||||
|
|
||||||
|
Elixir.Application.put_env(:sfe, Sfe.HomeLive, counter_ref: counter)
|
||||||
|
|
||||||
children = [
|
children = [
|
||||||
Sfe.Endpoint,
|
Sfe.Endpoint,
|
||||||
{Phoenix.PubSub, name: Sfe.PubSub}
|
{Phoenix.PubSub, name: Sfe.PubSub}
|
||||||
|
@ -116,7 +117,7 @@ defmodule Sfe.HomeLive do
|
||||||
dbg(:counters.sub(counter_ref(), 1, 1))
|
dbg(:counters.sub(counter_ref(), 1, 1))
|
||||||
counter_value(socket)
|
counter_value(socket)
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_info(%{topic: "counter", event: "counter", payload: cval}, socket) do
|
def handle_info(%{topic: "counter", event: "counter", payload: cval}, socket) do
|
||||||
{:noreply, assign(socket, :count, cval)}
|
{:noreply, assign(socket, :count, cval)}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue