#include #include #include "../shared/Messages.h" #include "../shared/SocketInfo.h" #include "../shared/InputFramework.h" #include "../shared/CommandDispatcher.h" #include "../shared/ReplyToClient.h" #include "../shared/NewConnections.h" #include "../shared/GlobalConfigFile.h" #include "../shared/DatabaseWithRetry.h" #include "UserInfo.h" #include "../ax_alert_server/AlertConfig.h" #include "../shared/Ping.h" #include "OddsMaker.h" #include "../shared/MarketHours.h" DatabaseWithRetry* database; DatabaseWithRetry* getDatabase() { if (!database) database = new DatabaseWithRetry(false, "monitorAliveRW"); return database; } static time_t lastMonitorAlive = 0; static void updateMonitorAlive() { time_t now; time(&now); if (now - lastMonitorAlive >= 59) { std::string sql = "UPDATE mydb.monitor_alive SET last_update = NOW() WHERE name = '" + getShortHostName() +" -> oddsmaker'"; getDatabase()->tryQueryUntilSuccess(sql); lastMonitorAlive = now; } } int main(int argc, char *argv[]) { setlocale(LC_ALL, ""); addConfigItems("listen_port=8802"); if (!addConfigItemsFromCommandLine(argv + 1)) { return 1; } configItemsComplete(); AllConfigInfo::init(); int listenPort = strtolDefault(getConfigItem("listen_port"), -1); if (listenPort == -1) { 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); } }