Run save every 10 minutes
This commit is contained in:
parent
164cf6a73a
commit
0a103b7b73
BIN
game_saves.db
BIN
game_saves.db
Binary file not shown.
17
src/Go.cr
17
src/Go.cr
|
@ -22,6 +22,15 @@ def save_game(db, gameid, game)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_all()
|
||||||
|
# Function: save_all
|
||||||
|
# Parameters: None
|
||||||
|
GAME_CACHE.each do |game_hash|
|
||||||
|
gameid, game = game_hash
|
||||||
|
save_game("none", gameid, game)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def query_game(db, gameid) : Go::Game?
|
def query_game(db, gameid) : Go::Game?
|
||||||
# Function: query_game
|
# Function: query_game
|
||||||
# Parameters: db(String)[Unused] gameid(String)
|
# Parameters: db(String)[Unused] gameid(String)
|
||||||
|
@ -196,4 +205,12 @@ ws "/game/:id" do |socket, env|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
spawn do
|
||||||
|
loop do
|
||||||
|
sleep 10.minute
|
||||||
|
puts "Saving"
|
||||||
|
save_all()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Fiber.yield
|
||||||
Kemal.run
|
Kemal.run
|
Loading…
Reference in New Issue
Block a user