dnsbty / level10

Phoenix LiveView multiplayer card game
https://level10.games
MIT License
72 stars 2 forks source link
elixir game multiplayer phoenix phoenix-liveview real-time websocket

Level10

A real-time multiplayer card game written with Phoenix LiveView

Animated gif of Level 10 in action

Development

After cloning the repo:

Now you can visit localhost:4000 from your browser.

Simulate clustering

Level 10 takes advantage of Erlang clustering for scale and uptime purposes. While in development mode, the application uses Libcluster's Gossip strategy if a node name is provided when starting the application.

Thus, clustering can be simulated by starting up the application as follows:

# In one terminal window
PORT=4000 iex --cookie level10 --name 4000 -S mix phx.server

# In a different terminal window
PORT=4001 iex --cookie level10 --name 4001 -S mix phx.server

State Handoff

Whenever a node is terminated gracefully with a SIGTERM (as would occur with a normal rolling deploy), any game processes hosted on that node will be handed off to one of the other nodes in the cluster via the Level10.StateHandoff module. In order to simulate this with a cluster running on your local machine, you can use the following command inside of iex for whichever node you'd like to terminate:

:init.stop()

Production

You can build a docker image that can run anywhere docker images can with docker build .

The official version of Level 10 runs in Digital Ocean Kubernetes. You can do the same by tweaking a few files in the deployment manifest and running kubectl apply -f k8s

Contributing

Information about contributing can be found in CONTRIBUTING.md