Hello! I’m writing a game app and am running into a couple issues that make me feel like I’m not organizing my project correctly. I’d greatly appreciate any pointers here. Thanks in advance.
I’m building an app where users connect over Phoenix channels, spinning up player state processes (GenServers) that connect to a game state process (also GenServer). The organization is as follows:
/state_app #genserver modules that manage player/game state /supervisor #supervisor module to spin up game/player/registry supervisors /websocket_server #phoenix, only used for websockets/channels /ecto_repo #connects to postgres for persistance
Ideally I just run the
state_app and everything starts up/is supervised by calls to the supervisor module.
I’m running into a couple issues:
I’m having trouble getting the supervisor module to manage the phoenix channel endpoint. I can point it to my endpoint module and start things up, but nothing gets served on :4000. :observer shows the processes running. I put
config :phoenix, :serve_endpoints, truein my dev.exs but no luck. Currently I have to start both the game state with
iex -S mixand then the phoenix server with
mix phx.serverin a separate window.
I have to put all my Ecto repo config into both the
websocket_serverconfig.exs, since I’m starting them separately. I think it’s because the configs for dependencies aren’t used? Does this mean I want to use an umbrella app?
I was hoping that the ecto repo / socket server would be stand-alone and I could minimize coupling in my code. Is my application just better suited to an umbrella app, am I organizing things incorrectly, or is it just configuration issues? Thanks much.