Changeset - 4d106deddda6
[Not reviewed]
0 4 0
HanzZ - 14 years ago 2011-07-09 17:07:44
hanzz.k@gmail.com
Added way to reload config ifle
4 files changed with 26 insertions and 2 deletions:
0 comments (0 inline, 0 general)
include/transport/config.h
Show inline comments
 
@@ -69,6 +69,8 @@ class Config {
 
		/// \param configfile path to config file
 
		bool load(const std::string &configfile);
 

	
 
		bool reload();
 

	
 
		/// Returns value of variable defined by key.
 
		
 
		/// For variables in sections you can use "section.variable" key format.
src/admininterface.cpp
Show inline comments
 
@@ -89,6 +89,15 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
 
		int users = m_userManager->getUserCount();
 
		message->setBody(boost::lexical_cast<std::string>(users));
 
	}
 
	else if (message->getBody() == "reload") {
 
		bool done = m_component->getConfig()->reload();
 
		if (done) {
 
			message->setBody("Config reloaded");
 
		}
 
		else {
 
			message->setBody("Error during config reload");
 
		}
 
	}
 
	else if (message->getBody() == "online_users_per_backend") {
 
		std::string lst;
 
		int id = 1;
 
@@ -125,8 +134,10 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
 
		help += "status - shows instance status\n";
 
		help += "online_users - returns list of all online users\n";
 
		help += "online_users_count - number of online users\n";
 
		help += "online_users_per_backend - shows online users per backends\n";
 
		help += "has_online_user <bare_JID> - returns 1 if user is online\n";
 
		help += "backends_count - number of active backends\n";
 
		help += "reload - Reloads config file\n";
 
		message->setBody(help);
 
	}
 
	else {
src/config.cpp
Show inline comments
 
@@ -74,4 +74,12 @@ bool Config::load(const std::string &configfile) {
 
	return load(configfile, opts);
 
}
 

	
 
bool Config::reload() {
 
	if (m_file.empty()) {
 
		return false;
 
	}
 

	
 
	return load(m_file);
 
}
 

	
 
}
src/networkpluginserver.cpp
Show inline comments
 
@@ -519,7 +519,7 @@ void NetworkPluginServer::handleUserCreated(User *user) {
 
	Backend *c = getFreeClient();
 
	if (!c) {
 
		LOG4CXX_ERROR(logger, "There is no backend to handle user " << user->getJID().toString());
 
		user->handleDisconnected("Internal Server Error, please reconnect.");
 
		user->handleDisconnected("Internal Server Error (no free backend to handle your session), please reconnect.");
 
		return;
 
	}
 
	user->setData(c);
 
@@ -804,10 +804,13 @@ NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient() {
 
	NetworkPluginServer::Backend *c = NULL;
 
	bool spawnNew = false;
 
	for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
 
		// This backend is free.
 
		if ((*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend")) {
 
			if ((*it)->users.size() + 1 == CONFIG_INT(m_config, "service.users_per_backend")) {
 
			// After this user, this backend could be full, so we have to spawn new one...
 
			if ((*it)->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
 
				spawnNew = true;
 
			}
 

	
 
			if (c == NULL) {
 
				c = *it;
 
			}
0 comments (0 inline, 0 general)