pidfile + working_dir
This commit is contained in:
parent
a481538836
commit
29d55fc4e4
2 changed files with 21 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "transport/networkpluginserver.h"
|
||||
#include "transport/admininterface.h"
|
||||
#include "Swiften/EventLoop/SimpleEventLoop.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#ifndef WIN32
|
||||
#include "sys/signal.h"
|
||||
#else
|
||||
|
@ -18,6 +19,7 @@
|
|||
#include "log4cxx/patternlayout.h"
|
||||
#include "log4cxx/propertyconfigurator.h"
|
||||
#include "log4cxx/consoleappender.h"
|
||||
#include "libgen.h"
|
||||
|
||||
using namespace log4cxx;
|
||||
|
||||
|
@ -161,7 +163,23 @@ int main(int argc, char **argv)
|
|||
|
||||
#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
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
|
|||
("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")
|
||||
|
|
Loading…
Add table
Reference in a new issue