Server wide variable?

Hello
Is it possible to set server-wide variables?
For example, in my init function, I would like to set a variable
StillBooting = true
and check this variable in all onBeforeAuth functions and don’t allow users to log in if this variable is not set to false in another part of the code.

We strongly suggest that you don’t use a global variable. What are you trying to achieve? A maintenance blocker? If so, why?

Whenever our instance restarts, we store all active matches in the database, to restore them later. After every restart, we experience about 15 minutes of heavy load to the database, so users who try to log in gets timeout on the database query.

We need to investigate this further, but the idea is, to block connections before all matches are restored successfully.

You should be doing match migration during reboots, and we strongly recommend against saving matches to the database.

We are running a lot of matches, and our nodes are using more than 50% of their RAM.
Migrating all matches to one node will cause an OutOfMemmory exception with all matches disappearing (been there, done that :slight_smile: )
Also storing matches in a database feels a lot safer than migrating them on flight to another node.

Any solution on how to make matches backups to be safe?
We don’t have a lot of client messages, (ie one client message in 1 min) so maybe save matches every client message into the database?

@jaggred You could abuse localcache and use that in matter of checking is game services still boothing.
in Lua you have nk.localcache_get , nk.localcache_put, nk.localcache_delete, nk.localcache_clear
https://github.com/heroiclabs/nakama/blob/master/server/runtime_lua_nakama.go
So basically in the main you would set a variable within localcache to be false, and once you call your method for creating all of the matches, i assume a function call is performed, once that function finishes set value of that variable to be true.

Maybe not the best case for using localcache but could work in your case.

Match migration automatically loadbalances all the matches across the all the nodes in the cluster, so not sure about this comment.

i use a backup/restore mechanism with the TypeScript Runtime. I store the whole matchState in nakamas storageengine (about every 10 seconds) and on bootup i restore all matches for that instance. In my case, matchState is about 500kb (json) and restoring hundreds of those matches gets done in less then a second.