#include #include #include "../shared/DatabaseForThread.h" #include "../shared/CommandDispatcher.h" #include "../shared/GlobalConfigFile.h" #include "../shared/MarketHours.h" #include "../shared/Ping.h" #include "../shared/NewConnections.h" #include "../shared/ReplyToClient.h" #include "../oddsmaker/UserInfo.h" #include "../ax_alert_server/AlertConfig.h" #include "MiscRODatabase.h" #include "MiscNFS.h" static time_t lastMonitorAlive = 0; static void updateMonitorAlive() { time_t now; time(&now); if (now - lastMonitorAlive >= 59) { DatabaseWithRetry &database = *DatabaseForThread(DatabaseWithRetry::MASTER); if (database.probablyWorks()) { std::string sql = "UPDATE mydb.monitor_alive SET last_update = NOW() WHERE name = '" + getShortHostName() + " -> misc_ms'"; database.tryQueryUntilSuccess(sql); lastMonitorAlive = now; } } } int main(int argc, char **argv) { setlocale(LC_ALL, ""); if (!addConfigItemsFromCommandLine(argv + 1)) { return 1; } configItemsComplete(); int listenPort = strtolDefault(getConfigItem("listen_port"), -1); if (listenPort < 0) { std::cerr<<"Invalid listen port \""<getInput(), commandDispatcher->getInputCallbackId()); // Start listening to new sockets now, after the other modules have // had time to configure themselves. NewConnections newConnections(&listener, listenPort); if (!newConnections.getSuccess()) { std::cerr<<"Unable to listen for new connections.\n"; return 3; } while (true) { updateMonitorAlive(); sleep(60); } }