 |
Kea
1.5.0
|
Go to the documentation of this file.
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 an unexpected error condition occurs.
virtual size_t writeConfigFile(const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
Writes current configuration to specified file.
isc::util::SignalHandler signal_handler_
Pointer to the common signal handler invoked by the handleSignal function.
virtual void handleSignal()
Invokes handler for the next received signal.
virtual void shutdown()
Initiates shutdown procedure for the whole DHCPv6 server.
void checkConfigFile() const
Checks the configuration file name.
void setDefaultLoggingOutput(bool verbose)
Reset root logger characteristics.
virtual void cleanup()
Performs final deconfiguration.
Class to Manipulate Filenames.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
Configures log4cplus by translating Kea configuration structures.
Class to help with processing PID files.
void setPIDFileDir(const std::string &pid_file_dir)
Sets the PID file directory.
std::string getConfigFile() const
Returns config file name.
static void configureLogger(const isc::data::ConstElementPtr &log_config, const isc::process::ConfigPtr &storage)
Configures logger.
void parseConfiguration(const isc::data::ConstElementPtr &log_config, bool verbose=false)
Parses specified configuration.
static bool getVerbose()
Returns if running in verbose mode.
static void loggerInit(const char *log_name, bool verbose)
Initializes logger.
void createPIDFile(int pid=0)
Creates the PID file.
const int MAX_DEBUG_LEVEL
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.
Defines the logger used by the top-level component of kea-dhcp-ddns.
isc::util::SignalSetPtr signal_set_
A pointer to the object installing custom signal handlers.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string makePIDFileName() const
Manufacture the pid file name.
static std::string getVersion(bool extended)
returns Kea version on stdout and exits.
A generic exception that is thrown if a function is called in a prohibited way.
void setPIDFileName(const std::string &pid_file_name)
Sets PID file name.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
std::string getProcName() const
returns the process name This value is used as when forming the default PID file name
virtual ~Daemon()
Destructor.
void setProcName(const std::string &proc_name)
Sets the process name.
std::string getPIDFileDir() const
Returns the directory used when forming default PID file name.
void initLogger(const string &root, isc::log::Severity severity, int dbglevel, const char *file, bool buffer)
Run-time initialization.
Exception thrown when a the PID file points to a live PID.
static void setVerbose(const bool verbose)
Sets or clears verbose mode.
Daemon()
Default constructor.
std::string getPIDFileName() const
Returns the current PID file name.
void setConfigFile(const std::string &config_file)
Sets the configuration file name.
A generic exception that is thrown when a function is not implemented.
boost::shared_ptr< const Element > ConstElementPtr
Logging initialization functions.