I'm connecting to mysql database using threaded connection OnPluginStart(). In my connect callback, I have function to retreive some test data with SQL_TQuery which inserts into some global vars and then PrintToConsole to test that it ran.
My problem is, when I launch my server, none of these functions seem to run. It's only when a client connects that the database decides to connect and function as it should. I need this data before any players connect - am I doing something wrong? I've tried this with non-threaded connect/query and it works as expected.
I've made a little progress - it seems because the server is booting up in hibernation mode. Once the server is running and I check "sm_cvar sv_hibernate_when_empty" it returns 1. If I switch it off, it boots and connects to the database. I've added "sm_cvar sv_hibernate_when_empty 0" however, when the server starts first time and runs the configs, it automatically goes into back into hibernation:
Code:
[SM] Changed cvar "sv_hibernate_when_empty" to "0".
Server waking up from hibernation
[SM] Changed cvar "sv_allow_wait_command" to "0".
[SM] Changed cvar "sv_pausable" to "0".
[SM] Changed cvar "sv_voiceenable" to "1".
[SM] Changed cvar "sv_alltalk" to "1".
Server is hibernating
How would I go about starting out of hibernation mode the first time the server boots. Seems like it wants to force itself into hibernation mode on it's first boot and that means I can't even set up a timer to force it to unhibernate.
edit: well, I noticed that after server was forcing itself into hibernation, the l4d2 event round_end was firing. So I hooked it and set "sm_cvar sv_hibernate_when_empty 0" there, which works to wake it up and launch database functions. It's messy but it works for now.