-// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
Daemon::loggerInit(bin_name_.c_str(), verbose_);
}
+ try {
+ checkConfigFile();
+ } catch (const std::exception& ex) {
+ LOG_FATAL(dctl_logger, DCTL_CONFIG_FILE_LOAD_FAIL)
+ .arg(app_name_).arg(ex.what());
+ isc_throw (LaunchError, "Launch Failed: " << ex.what());
+ }
+
try {
createPIDFile();
} catch (const DaemonPIDExists& ex) {
config_file_ = config_file;
}
+void
+Daemon::checkConfigFile() const {
+ if (config_file_.empty()) {
+ isc_throw(isc::BadValue, "config file name is not set");
+ }
+
+ // Create Filename instance from the config_file_ pathname, and
+ // check the file name component.
+ isc::util::Filename file(config_file_);
+ if (file.name().empty()) {
+ isc_throw(isc::BadValue, "config file:" << config_file_
+ << " is missing file name");
+ }
+}
+
std::string
Daemon::getProcName() const {
return (proc_name_);
"Daemon::makePIDFileName config file name is not set");
}
- if (proc_name_.empty()) {
- isc_throw(isc::InvalidOperation,
- "Daemon::makePIDFileName process name is not set");
- }
-
// Create Filename instance from the config_file_ pathname, so we can
// extract the fname component.
isc::util::Filename file(config_file_);
<< config_file_ << " is missing file name");
}
+ if (proc_name_.empty()) {
+ isc_throw(isc::InvalidOperation,
+ "Daemon::makePIDFileName process name is not set");
+ }
+
// Make the pathname for the PID file from the runtime directory,
// configuration name and process name.
std::ostringstream stream;
/// @param config_file pathname of the configuration file
void setConfigFile(const std::string& config_file);
+ /// @brief Checks the configuration file name.
+ /// @throw BadValue when the configuration file name is bad.
+ void checkConfigFile() const;
+
/// @brief Writes current configuration to specified file
///
/// This method writes the current configuration to specified file.
-// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
if (pid == 0) {
// This is the child, die right away. Tragic, no?
- exit (0);
+ _exit (0);
}
// Back in the parent test, we need to wait for the child to die