17 #include <boost/bind.hpp> 30 bool Daemon::verbose_ =
false;
32 std::string Daemon::default_logger_name_(
"kea");
35 : signal_set_(), signal_handler_(), config_file_(
""), proc_name_(
""),
36 pid_file_dir_(DATA_DIR), pid_file_(), am_file_author_(false) {
40 const char*
const env = getenv(
"KEA_PIDFILE_DIR");
47 if (pid_file_ && am_file_author_) {
48 pid_file_->deleteFile();
90 setenv(
"KEA_LOGGER_DESTINATION",
"stdout", 0);
106 return (config_file_);
111 config_file_ = config_file;
116 if (config_file_.empty()) {
123 if (file.
name().empty()) {
125 <<
" is missing file name");
136 proc_name_ = proc_name;
141 return(pid_file_dir_);
146 pid_file_dir_ = pid_file_dir;
152 return (pid_file_->getFilename());
162 " file name already set to:" << pid_file_->getFilename());
165 if (pid_file_name.empty()) {
167 " file name may not be empty");
175 if (config_file_.empty()) {
177 "Daemon::makePIDFileName config file name is not set");
183 if (file.
name().empty()) {
185 << config_file_ <<
" is missing file name");
188 if (proc_name_.empty()) {
190 "Daemon::makePIDFileName process name is not set");
195 std::ostringstream stream;
196 stream << pid_file_dir_ <<
"/" << file.
name()
197 <<
"." << proc_name_ <<
".pid";
199 return(stream.str());
211 int chk_pid = pid_file_->check();
222 pid_file_->write(pid);
225 am_file_author_ =
true;
235 std::ofstream out(config_file, std::ios::trunc);
243 size_t bytes = static_cast<size_t>(out.tellp());
A generic exception that is thrown when a function is not implemented.
void setDefaultLoggingOutput(bool verbose)
Reset root logger characteristics.
void setPIDFileName(const std::string &pid_file_name)
Sets PID file name.
virtual void handleSignal()
Invokes handler for the next received signal.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
void checkConfigFile() const
Checks the configuration file name.
std::string getProcName() const
returns the process name This value is used as when forming the default PID file name
virtual void shutdown()
Initiates shutdown procedure for the whole DHCPv6 server.
isc::util::SignalSetPtr signal_set_
A pointer to the object installing custom signal handlers.
virtual void cleanup()
Performs final deconfiguration.
virtual ~Daemon()
Destructor.
Class to help with processing PID files.
std::string getConfigFile() const
Returns config file name.
void parseConfiguration(const isc::data::ConstElementPtr &log_config, bool verbose=false)
Parses specified configuration.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
void setProcName(const std::string &proc_name)
Sets the process name.
A generic exception that is thrown when an unexpected error condition occurs.
void setConfigFile(const std::string &config_file)
Sets the configuration file name.
boost::shared_ptr< const Element > ConstElementPtr
static std::string getVersion(bool extended)
returns Kea version on stdout and exits.
static void setVerbose(const bool verbose)
Sets or clears verbose mode.
Defines the logger used by the top-level component of kea-dhcp-ddns.
std::string getPIDFileName() const
Returns the current PID file name.
static void loggerInit(const char *log_name, bool verbose)
Initializes logger.
Logging initialization functions.
virtual size_t writeConfigFile(const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
Writes current configuration to specified file.
Configures log4cplus by translating Kea configuration structures.
A generic exception that is thrown if a function is called in a prohibited way.
static bool getVerbose()
Returns if running in verbose mode.
isc::util::SignalHandler signal_handler_
Pointer to the common signal handler invoked by the handleSignal function.
void setPIDFileDir(const std::string &pid_file_dir)
Sets the PID file directory.
Exception thrown when a the PID file points to a live PID.
void initLogger(const string &root, isc::log::Severity severity, int dbglevel, const char *file, bool buffer)
Run-time initialization.
std::string getPIDFileDir() const
Returns the directory used when forming default PID file name.
void createPIDFile(int pid=0)
Creates the PID file.
Class to Manipulate Filenames.
Daemon()
Default constructor.
const int MAX_DEBUG_LEVEL
std::string makePIDFileName() const
Manufacture the pid file name.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.
static void configureLogger(const isc::data::ConstElementPtr &log_config, const isc::process::ConfigPtr &storage)
Configures logger.