dnsbty / level10

Phoenix LiveView multiplayer card game

Home Page:https://level10.games

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Level10

A real-time multiplayer card game written with Phoenix LiveView

Animated gif of Level 10 in action

Development

After cloning the repo:

  • Install dependencies with mix deps.get
  • Install Node.js dependencies with (cd assets && yarn)
  • Start Phoenix endpoint with mix phx.server

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

About

Phoenix LiveView multiplayer card game

https://level10.games

License:MIT License


Languages

Language:Elixir 92.0%Language:HTML 6.0%Language:JavaScript 1.3%Language:Dockerfile 0.3%Language:CSS 0.2%Language:Shell 0.1%