36bool Daemon::verbose_ =
false;
38std::string Daemon::proc_name_(
"");
40std::string Daemon::default_logger_name_(
"kea");
44 pid_file_dir_(PIDFILE_DIR), pid_file_(), am_file_author_(false),
45 exit_value_(EXIT_SUCCESS) {
49 const char*
const env = getenv(
"KEA_PIDFILE_DIR");
56 if (pid_file_ && am_file_author_) {
57 pid_file_->deleteFile();
91 setenv(
"KEA_LOGGER_DESTINATION",
"stdout", 0);
106 return (config_file_);
111 config_file_ = config_file;
116 if (config_file_.empty()) {
123 if (
file.stem().empty()) {
125 <<
" is missing file name");
133 if (path.
stem().empty()) {
135 <<
" is missing file name");
137 Path current(config_file_);
148 <<
"directory as the config file (" << config_file_ <<
")");
158 proc_name_ = proc_name;
163 return(pid_file_dir_);
168 pid_file_dir_ = pid_file_dir;
174 return (pid_file_->getFilename());
183 return (pid_file_->getLockname());
193 " file name already set to:" << pid_file_->getFilename());
196 if (pid_file_name.empty()) {
198 " file name may not be empty");
201 pid_file_.reset(
new PIDFile(pid_file_name));
206 if (config_file_.empty()) {
208 "Daemon::makePIDFileName config file name is not set");
214 if (
file.stem().empty()) {
216 << config_file_ <<
" is missing file name");
219 if (proc_name_.empty()) {
221 "Daemon::makePIDFileName process name is not set");
226 std::ostringstream stream;
227 stream << pid_file_dir_ <<
"/" <<
file.stem()
228 <<
"." << proc_name_ <<
".pid";
230 return(stream.str());
249 int chk_pid = pid_file_->check();
260 pid_file_->write(pid);
263 am_file_author_ =
true;
273 std::ofstream out(config_file, std::ios::trunc);
281 size_t bytes =
static_cast<size_t>(out.tellp());
288std::list<std::list<std::string>>
290 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.
isc::asiolink::IOSignalSetPtr signal_set_
A pointer to the object installing custom signal handlers.
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.
void checkWriteConfigFile(std::string &file)
Checks the to-be-written configuration file name.
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 getPIDLockName() const
Returns the current PID lock file name.
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.
RAII device to handle a lock file to avoid race conditions.
bool isLocked()
Return the lock status.
#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, string obscure)
Redact a configuration.
Defines the logger used by the top-level component of kea-lfc.
std::string parentDirectory() const
Get the parent directory.
std::string stem() const
Get the base name of the file without the extension.