euchre-live

Euchre web-app for the socially distant family
git clone git://git.alexkarle.com/euchre-live.git
Log | Files | Refs | README | LICENSE

commit 1391e546a4ae2a3f235e14fb019c458ddb5b5ced (patch)
parent adffa051d2195f115fc5f8e49e8178cc8cb31674
Author: Alex Karle <alex@karle.co>
Date:   Wed, 22 Apr 2020 23:02:39 -0400

Euchre::Dealer: Add simple text stats endpoint

$ curl euchre.live/stats

Gotta make sure nobody is in a live game when I'm rolling out updates to
the server! :)

Of course, hot reloading may be a feature one day. But today, < 10
people know it's "live" in any form so that's not an issue.

Diffstat:
Mgloat.pl | 5+++++
Mlib/Euchre/Dealer.pm | 14++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/gloat.pl b/gloat.pl @@ -22,6 +22,11 @@ get '/debug' => sub { $c->reply->static('debug.html'); }; +get '/stats' => sub { + my $c = shift; + $c->render(text => stats); +}; + websocket '/play' => sub { my $c = shift; diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm @@ -15,6 +15,7 @@ our @EXPORT = qw( handle_msg register_player gloaters_never_win + stats ); # XXX: The first draft of this was written quickly and chose @@ -595,4 +596,17 @@ sub swap_player { return 0; } +# Global server stats for games in progress +# Poor man's monitoring :) +sub stats { + my $num_players = scalar keys %PLAYERS; + my $num_games = scalar keys %GAMES; + + return <<"EOM" +$num_players\tPlayers +$num_games\tGames +EOM + +} + 1;