Import T5-AIO and T6 into combined repo
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/* tws_db.gsc — MariaDB pool + reachability probe. Fires db_probe_done. */
|
||||
|
||||
#include maps\_utility;
|
||||
#include common_scripts\utility;
|
||||
|
||||
init()
|
||||
{
|
||||
if (GetDvar(#"zombiemode") != "1")
|
||||
return;
|
||||
|
||||
scripts\sp\tws_common::ensure_config();
|
||||
|
||||
db_init();
|
||||
}
|
||||
|
||||
// TODO: move creds to dvars before this repo goes public
|
||||
db_init()
|
||||
{
|
||||
level.db_online = false;
|
||||
level.db_probe_done = false;
|
||||
|
||||
cfg = spawnStruct();
|
||||
cfg.host = "mariadb";
|
||||
cfg.user = "josh";
|
||||
cfg.password = "joshster";
|
||||
cfg.port = 3306;
|
||||
cfg.database = "tws_zm";
|
||||
|
||||
mysql::set_config(cfg);
|
||||
|
||||
level thread db_probe();
|
||||
}
|
||||
|
||||
// set_config is silent on failure; only a real query surfaces the error
|
||||
db_probe()
|
||||
{
|
||||
q = mysql::query("SELECT 1 AS ok");
|
||||
q waittill("done", result, affected_rows, error);
|
||||
|
||||
if (isDefined(error) && error != "")
|
||||
level.db_online = false;
|
||||
else
|
||||
level.db_online = true;
|
||||
|
||||
level.db_probe_done = true;
|
||||
level notify("db_probe_done");
|
||||
}
|
||||
Reference in New Issue
Block a user