Changeset - 29d55fc4e424
[Not reviewed]
0 2 0
HanzZ - 14 years ago 2011-09-08 16:51:11
hanzz.k@gmail.com
pidfile + working_dir
2 files changed with 21 insertions and 1 deletions:
0 comments (0 inline, 0 general)
spectrum/src/main.cpp
Show inline comments
 
@@ -5,22 +5,24 @@
 
#include "transport/sqlite3backend.h"
 
#include "transport/mysqlbackend.h"
 
#include "transport/userregistration.h"
 
#include "transport/networkpluginserver.h"
 
#include "transport/admininterface.h"
 
#include "Swiften/EventLoop/SimpleEventLoop.h"
 
#include <boost/filesystem.hpp>
 
#ifndef WIN32
 
#include "sys/signal.h"
 
#else
 
#include <Windows.h>
 
#include <tchar.h>
 
#endif
 
#include "log4cxx/logger.h"
 
#include "log4cxx/patternlayout.h"
 
#include "log4cxx/propertyconfigurator.h"
 
#include "log4cxx/consoleappender.h"
 
#include "libgen.h"
 
 
using namespace log4cxx;
 
 
using namespace Transport;
 
 
Swift::SimpleEventLoop *eventLoop_ = NULL;
 
@@ -158,13 +160,29 @@ int main(int argc, char **argv)
 
		std::cerr << "Can't load configuration file.\n";
 
		return 1;
 
	}
 
 
#ifndef WIN32
 
	if (!no_daemon) {
 
		daemonize("/", NULL);
 
		try {
 
			boost::filesystem::create_directories(CONFIG_STRING(&config, "service.working_dir"));
 
		}
 
		catch (...) {
 
			std::cerr << "Can't create service.working_dir directory " << CONFIG_STRING(&config, "service.working_dir") << ".\n";
 
			return 1;
 
		}
 
		try {
 
			boost::filesystem::create_directories(
 
				boost::filesystem::path(CONFIG_STRING(&config, "service.pidfile")).parent_path().string()
 
			);
 
		}
 
		catch (...) {
 
			std::cerr << "Can't create service.pidfile directory " << boost::filesystem::path(CONFIG_STRING(&config, "service.pidfile")).parent_path().string() << ".\n";
 
			return 1;
 
		}
 
		daemonize(CONFIG_STRING(&config, "service.working_dir").c_str(), CONFIG_STRING(&config, "service.pidfile").c_str());
 
	}
 
#endif
 
 
	if (CONFIG_STRING(&config, "logging.config").empty()) {
 
		LoggerPtr root = log4cxx::Logger::getRootLogger();
 
#ifdef WIN32
src/config.cpp
Show inline comments
 
@@ -49,12 +49,14 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		("service.jid", value<std::string>()->default_value(""), "Transport Jabber ID")
 
		("service.server", value<std::string>()->default_value(""), "Server to connect to")
 
		("service.password", value<std::string>()->default_value(""), "Password used to auth the server")
 
		("service.port", value<int>()->default_value(0), "Port the server is listening on")
 
		("service.backend", value<std::string>()->default_value("libpurple_backend"), "Backend")
 
		("service.protocol", value<std::string>()->default_value(""), "Protocol")
 
		("service.pidfile", value<std::string>()->default_value("/var/run/spectrum2/spectrum2.pid"), "Full path to pid file")
 
		("service.working_dir", value<std::string>()->default_value("/var/lib/spectrum2"), "Working dir")
 
		("service.allowed_servers", value<std::string>()->default_value(""), "Only users from these servers can connect")
 
		("service.server_mode", value<bool>()->default_value(false), "True if Spectrum should behave as server")
 
		("service.users_per_backend", value<int>()->default_value(100), "Number of users per one legacy network backend")
 
		("service.backend_host", value<std::string>()->default_value("localhost"), "Host to bind backend server to")
 
		("service.backend_port", value<std::string>()->default_value("10000"), "Port to bind backend server to")
 
		("service.cert", value<std::string>()->default_value(""), "PKCS#12 Certificate.")
0 comments (0 inline, 0 general)