35bool Daemon::verbose_ =
false;
37std::string Daemon::proc_name_(
"");
39std::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()) {
121 Path file(config_file_);
122 if (file.
stem().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");
181 Path file(config_file_);
182 if (file.
stem().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.
stem()
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;
237 std::ofstream out(config_file, std::ios::trunc);
245 size_t bytes =
static_cast<size_t>(out.tellp());
252std::list<std::list<std::string>>
254 static std::list<std::list<std::string>>
const list;
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when a function is not implemented.
A generic exception that is thrown when an unexpected error condition occurs.
Exception thrown when the PID file points to a live PID.
std::string getConfigFile() const
Returns config file name.
virtual size_t writeConfigFile(const std::string &config_file, isc::data::ConstElementPtr cfg=isc::data::ConstElementPtr()) const
Writes current configuration to specified file.
static std::string getVersion(bool extended)
returns Kea version on stdout and exits.
static void setVerbose(const bool verbose)
Sets or clears verbose mode.
std::string getPIDFileName() const
Returns the current PID file name.
virtual std::list< std::list< std::string > > jsonPathsToRedact() const
Return a list of all paths that contain passwords or secrets.
Daemon()
Default constructor.
virtual void shutdown()
Initiates shutdown procedure for the whole server.
std::string getPIDFileDir() const
Returns the directory used when forming default PID file name.
virtual ~Daemon()
Destructor.
static void configureLogger(const isc::data::ConstElementPtr &log_config, const isc::process::ConfigPtr &storage)
Configures logger.
static bool getVerbose()
Returns if running in verbose mode.
static void loggerInit(const char *log_name, bool verbose)
Initializes logger.
static std::string getProcName()
returns the process name This value is used as when forming the default PID file name
virtual void cleanup()
Performs final deconfiguration.
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config)
Redact a configuration.
void checkConfigFile() const
Checks the configuration file name.
void setPIDFileName(const std::string &pid_file_name)
Sets PID file name.
static void setProcName(const std::string &proc_name)
Sets the process name.
void createPIDFile(int pid=0)
Creates the PID file.
void setPIDFileDir(const std::string &pid_file_dir)
Sets the PID file directory.
std::string makePIDFileName() const
Manufacture the pid file name.
void setConfigFile(const std::string &config_file)
Sets the configuration file name.
Configures log4cplus by translating Kea configuration structures.
void parseConfiguration(const isc::data::ConstElementPtr &log_config, bool verbose=false)
Parses specified configuration.
Class to help with processing PID files.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Logging initialization functions.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
boost::shared_ptr< const Element > ConstElementPtr
void initLogger(const string &root, isc::log::Severity severity, int dbglevel, const char *file, bool buffer)
Run-time initialization.
const int MAX_DEBUG_LEVEL
void setDefaultLoggingOutput(bool verbose)
Reset root logger characteristics.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
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 stem() const
Get the base name of the file without the extension.
RAII device to limit access of created files.