summaryrefslogtreecommitdiffstats
path: root/src/account-server/main-account.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-26 22:59:03 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-26 22:59:03 +0100
commitb92c3f2e1c6a4d6ed87ed596f97d268fc4c53785 (patch)
tree32079432854736c6cd4c2285b8774ff4703dc83e /src/account-server/main-account.cpp
parentfeb848940855a8001a65252ee727887be8e2cf35 (diff)
downloadmanaserv-b92c3f2e1c6a4d6ed87ed596f97d268fc4c53785.tar.gz
manaserv-b92c3f2e1c6a4d6ed87ed596f97d268fc4c53785.tar.xz
manaserv-b92c3f2e1c6a4d6ed87ed596f97d268fc4c53785.zip
Add an heartbeat time flag in the statistics file.
This way, any kind of external service can know about the running state of each servers, even if only the account server is updating the statistics because: 1. When the account server is running, each <gameserver> tag is a running game server. Otherwise, it's not listed. 2. Whenever the account server stops running, the stat file isn't updated anymore and so the <heartbeat> tag isn't. 3. Game servers without any contact with an account server will try to reconnect to the account server and kick out every players so they aren't considered as running in that case. Reviewed-by: Crush. Resolves: Mana-mantis #270.
Diffstat (limited to 'src/account-server/main-account.cpp')
-rw-r--r--src/account-server/main-account.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index ae24ee6..25e9623 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -38,6 +38,7 @@
#include "utils/logger.h"
#include "utils/processorutils.h"
#include "utils/stringfilter.h"
+#include "utils/time.h"
#include "utils/timer.h"
#include "defines.h"
#include "manaserv_protocol.h"
@@ -245,10 +246,19 @@ static void deinitializeServer()
/**
* Dumps statistics.
*/
-static void dumpStatistics()
+static void dumpStatistics(std::string accountAddress, int accountClientPort,
+ int accountGamePort, int chatClientPort)
{
std::ofstream os(statisticsFile.c_str());
os << "<statistics>\n";
+ // Print last heartbeat
+ os << "<heartbeat=\"" << utils::getCurrentDate() << "_"
+ << utils::getCurrentTime() << "\" />\n";
+ // Add account server information
+ os << "<accountserver address=\"" << accountAddress << "\" clientport=\""
+ << accountClientPort << "\" gameport=\"" << accountGamePort
+ << "\" chatclientport=\"" << chatClientPort << "\" />\n";
+ // Add game servers information
GameServerHandler::dumpStatistics(os);
os << "</statistics>\n";
}
@@ -425,7 +435,8 @@ int main(int argc, char *argv[])
chatHandler->process(50);
if (statTimer.poll())
- dumpStatistics();
+ dumpStatistics(accountHost, options.port, accountGamePort,
+ chatClientPort);
if (banTimer.poll())
storage->checkBannedAccounts();