mix phx.server working

This commit is contained in:
Daniel Flanagan 2024-02-20 22:15:26 -06:00
parent 0f1131b406
commit 840cbe251c
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
2 changed files with 19 additions and 18 deletions

35
main.ex
View file

@ -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

View file

@ -17,7 +17,7 @@ and is used for nice things like code reloading by Phoenix, so not _quite_ as
So here ya go! So here ya go!
```bash ```bash
elixir main.ex mix phx.server
``` ```
Or if you want "hot reloading" Or if you want "hot reloading"