Config file tweaks
This commit is contained in:
parent
f4df7fdd4e
commit
a481538836
3 changed files with 98 additions and 33 deletions
|
@ -1,25 +1,88 @@
|
|||
[service]
|
||||
jid = localhost
|
||||
password = secret
|
||||
server = 127.0.0.1
|
||||
port = 5222
|
||||
# 1 if Spectrum should run in server mode.
|
||||
server_mode = 1
|
||||
backend_host=localhost # < this option doesn't work yet
|
||||
|
||||
# JID of Spectrum instance.
|
||||
jid = localhost
|
||||
|
||||
# Password used to connect the XMPP server in gateway mode.
|
||||
# In server mode, this option is ignored.
|
||||
password = secret
|
||||
|
||||
# XMPP server to which Spectrum connects in gateway mode.
|
||||
# In server mode, this option is ignored.
|
||||
server = 127.0.0.1
|
||||
|
||||
# XMPP server port.
|
||||
port = 5222
|
||||
|
||||
# Interface on which Spectrum listens for backends.
|
||||
backend_host = localhost
|
||||
|
||||
# Port on which Spectrum listens for backends.
|
||||
backend_port=10001
|
||||
#cert= #patch to PKCS#12 certificate
|
||||
#cert_password= #password to that certificate if any
|
||||
users_per_backend=1
|
||||
backend=spectrum_libpurple_backend
|
||||
#backend=spectrum_libircclient-qt_backend
|
||||
|
||||
# Full path to PKCS#12 cetficiate used for TLS in server mode.
|
||||
#cert=
|
||||
|
||||
# Certificate password if any.
|
||||
#cert_password=
|
||||
|
||||
# Number of users per one legacy network backend.
|
||||
users_per_backend=10
|
||||
|
||||
# Full path to backend binary.
|
||||
backend=/usr/bin/spectrum_libpurple_backend
|
||||
#backend=/usr/bin/spectrum_libircclient-qt_backend
|
||||
|
||||
# Libpurple protocol-id for spectrum_libpurple_backend
|
||||
protocol=prpl-jabber
|
||||
#protocol=prpl-msn
|
||||
#protocol=prpl-icq
|
||||
|
||||
# prpl-any means that user sets his protocol in his JID which has to be
|
||||
# in following format: protocol.username@domain.tld
|
||||
# So for example: prpl-jabber.hanzz.k%gmail.com@domain.tld
|
||||
#protocol=prpl-any
|
||||
|
||||
[identity]
|
||||
# Name of Spectrum instance in service discovery
|
||||
name=Spectrum Jabber Transport
|
||||
|
||||
# Type of transport ("msn", "icq", "xmpp").
|
||||
# Check http://xmpp.org/registrar/disco-categories.html#gateway
|
||||
type=xmpp
|
||||
|
||||
# Category of transport, default is "gateway
|
||||
#category=gateway
|
||||
|
||||
[logging]
|
||||
#config=logging.cfg # log4cxx/log4j logging configuration file
|
||||
# log4cxx/log4j logging configuration file in ini format used for main spectrum2 instance.
|
||||
#config = logging.cfg
|
||||
|
||||
# log4cxx/log4j logging configuration file in ini format used for backends.
|
||||
#backend_config=backend_logging.cfg # log4cxx/log4j logging configuration file for backends
|
||||
|
||||
[database]
|
||||
type = none # "sqlite3" or "none" without database backend
|
||||
database = test.sql
|
||||
#prefix=icq
|
||||
# Database backend type
|
||||
# "sqlite3", "mysql" or "none" without database backend
|
||||
type = none
|
||||
|
||||
# For SQLite3: Full path to database
|
||||
# For MySQL: name of database
|
||||
database = jabber_transport
|
||||
|
||||
# Server.
|
||||
server = localhost
|
||||
|
||||
# Port.
|
||||
port = 0
|
||||
|
||||
# User.
|
||||
user = spectrum
|
||||
|
||||
# Paasword.
|
||||
password = secret
|
||||
|
||||
# Prefix used for tables
|
||||
prefix = jabber_
|
||||
|
|
|
@ -62,7 +62,7 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
|
|||
("service.admin_username", value<std::string>()->default_value(""), "Administrator username.")
|
||||
("service.admin_password", value<std::string>()->default_value(""), "Administrator password.")
|
||||
("service.reuse_old_backends", value<bool>()->default_value(true), "True if Spectrum should use old backends which were full in the past.")
|
||||
("service.idle_reconnect_time", value<int>()->default_value(4*3600), "Time in seconds after which idle users are reconnected to let their backend die.")
|
||||
("service.idle_reconnect_time", value<int>()->default_value(0), "Time in seconds after which idle users are reconnected to let their backend die.")
|
||||
("service.more_resources", value<bool>()->default_value(false), "Allow more resources to be connected in server mode at the same time.")
|
||||
("identity.name", value<std::string>()->default_value("Spectrum 2 Transport"), "Name showed in service discovery.")
|
||||
("identity.category", value<std::string>()->default_value("gateway"), "Disco#info identity category. 'gateway' by default.")
|
||||
|
|
|
@ -669,30 +669,32 @@ void NetworkPluginServer::pingTimeout() {
|
|||
// Some users are connected for weeks and they are blocking backend to be destroyed and its memory
|
||||
// to be freed. We are finding users who are inactive for more than "idle_reconnect_time" seconds and
|
||||
// reconnect them to long-running backend, where they can idle hapilly till the end of ages.
|
||||
time_t now = time(NULL);
|
||||
std::vector<User *> usersToMove;
|
||||
unsigned long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
|
||||
for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
|
||||
// Users from long-running backends can't be moved
|
||||
if ((*it)->longRun) {
|
||||
continue;
|
||||
}
|
||||
if (diff != 0) {
|
||||
time_t now = time(NULL);
|
||||
std::vector<User *> usersToMove;
|
||||
|
||||
for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
|
||||
// Users from long-running backends can't be moved
|
||||
if ((*it)->longRun) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find users which are inactive for more than 'diff'
|
||||
BOOST_FOREACH(User *u, (*it)->users) {
|
||||
if (now - u->getLastActivity() > diff) {
|
||||
usersToMove.push_back(u);
|
||||
// Find users which are inactive for more than 'diff'
|
||||
BOOST_FOREACH(User *u, (*it)->users) {
|
||||
if (now - u->getLastActivity() > diff) {
|
||||
usersToMove.push_back(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move inactive users to long-running backend.
|
||||
BOOST_FOREACH(User *u, usersToMove) {
|
||||
LOG4CXX_INFO(logger, "Moving user " << u->getJID().toString() << " to long-running backend");
|
||||
if (!moveToLongRunBackend(u))
|
||||
break;
|
||||
// Move inactive users to long-running backend.
|
||||
BOOST_FOREACH(User *u, usersToMove) {
|
||||
LOG4CXX_INFO(logger, "Moving user " << u->getJID().toString() << " to long-running backend");
|
||||
if (!moveToLongRunBackend(u))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// check ping responses
|
||||
|
|
Loading…
Add table
Reference in a new issue