hangry-river-horse
hangry-river-horse copied to clipboard
Auto-update host site
Currently, when a new version of the app is deployed, any open host displays have to be manually refreshed. It would be better if the host site could automatically detect that a new version has gone live and refresh itself.
The host site can already detect when it disconnects from the server via the websocket's onclose
event. When the websocket closes, the host should throw up a "Disconnected from server" message, and start pinging the server to see if it's online. Once the server comes back online, the host page can simply refresh itself using window.location.reload(true);
.
We should add a simple endpoint to the server that the host page can use to check if the server is online, something like /api/ping
(it wouldn't have to interact with the game state at all, it could simply respond "pong" to every request). We should also include some kind of back-off or delay mechanism between requests so as to avoid flooding the EC2 instance with requests when the server is down.