26 namespace ph = std::placeholders;
35 bool Daemon::verbose_ =
false;
37 std::string Daemon::proc_name_(
"");
39 std::string Daemon::default_logger_name_(
"kea");
42 : signal_set_(), config_file_(
""),
43 pid_file_dir_(DATA_DIR), pid_file_(), am_file_author_(false),
44 exit_value_(EXIT_SUCCESS) {
48 const char*
const env = getenv(
"KEA_PIDFILE_DIR");
55 if (pid_file_ && am_file_author_) {
56 pid_file_->deleteFile();
90 setenv(
"KEA_LOGGER_DESTINATION",
"stdout", 0);
105 return (config_file_);
110 config_file_ = config_file;
115 if (config_file_.empty()) {
122 if (file.
name().empty()) {
124 <<
" is missing file name");
135 proc_name_ = proc_name;
140 return(pid_file_dir_);
145 pid_file_dir_ = pid_file_dir;
151 return (pid_file_->getFilename());
161 " file name already set to:" << pid_file_->getFilename());
164 if (pid_file_name.empty()) {
166 " file name may not be empty");
174 if (config_file_.empty()) {
176 "Daemon::makePIDFileName config file name is not set");
182 if (file.
name().empty()) {
184 << config_file_ <<
" is missing file name");
187 if (proc_name_.empty()) {
189 "Daemon::makePIDFileName process name is not set");
194 std::ostringstream stream;
195 stream << pid_file_dir_ <<
"/" << file.
name()
196 <<
"." << proc_name_ <<
".pid";
198 return(stream.str());
210 int chk_pid = pid_file_->check();
221 pid_file_->write(pid);
224 am_file_author_ =
true;
234 std::ofstream out(config_file, std::ios::trunc);
242 size_t bytes =
static_cast<size_t>(out.tellp());
249 std::list<std::list<std::string>>
251 static std::list<std::list<std::string>>
const list;
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.
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.
virtual void shutdown()
Initiates shutdown procedure for the whole server.
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...
static 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
virtual std::list< std::list< std::string > > jsonPathsToRedact() const
Return a list of all paths that contain passwords or secrets.
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
static std::string getVersion(bool extended)
returns Kea version on stdout and exits.
static void setVerbose(const bool verbose)
Sets or clears verbose mode.
ConstElementPtr redactConfig(ConstElementPtr const &element, list< string > const &json_path)
Redact a configuration.
Defines the logger used by the top-level component of kea-lfc.
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.
static std::string getProcName()
returns the process name This value is used as when forming the default PID file name ...
void setPIDFileDir(const std::string &pid_file_dir)
Sets the PID file directory.
Exception thrown when 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.
const int MAX_DEBUG_LEVEL
std::string makePIDFileName() const
Manufacture the pid file name.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
static void configureLogger(const isc::data::ConstElementPtr &log_config, const isc::process::ConfigPtr &storage)
Configures logger.