throw; // rethrow it
}
- Daemon::setProcName(bin_name_);
+ setProcName(bin_name_);
// It is important that we set a default logger name because this name
// will be used when the user doesn't provide the logging configuration
isc_throw(InvalidUsage, "configuration file name missing");
}
- Daemon::setConfigFile(optarg);
+ setConfigFile(optarg);
break;
case '?': {
// Remember verbose-mode
server.setVerbose(verbose_mode);
- Daemon::setProcName(DHCP4_NAME);
- Daemon::setConfigFile(config_file);
+ // Create our PID file.
+ server.setProcName(DHCP4_NAME);
+ server.setConfigFile(config_file);
server.createPIDFile();
try {
to receive DHCPv6 traffic. IPv6 socket on this interface will be opened once
Interface Manager starts up procedure of opening sockets.
+% DHCP6_ALREADY_RUNNING %1 already running? %2
+This is an error message that occurs when the DHCPv6 server encounters
+a pre-existing PID file which contains the PID of a running process.
+This most likely indicates an attempt to start a second instance of
+the server using the same configuration file. It is possible, though
+unlikely that the PID file is a remnant left behind by a server crash or
+power failure and the PID it contains refers to a process other than
+the server. In such an event, it would be necessary to manually remove
+the PID file.
+
% DHCP6_ADD_GLOBAL_STATUS_CODE %1: adding Status Code to DHCPv6 packet: %2
This message is logged when the server is adding the top-level
Status Code option. The first argument includes the client and the
void
ControlledDhcpv6Srv::init(const std::string& file_name) {
- // Call parent class's init to initialize file name.
- Daemon::init(file_name);
-
// Configure the server using JSON file.
configure(file_name);
// Remember verbose-mode
server.setVerbose(verbose_mode);
+ // Create our PID file
+ server.setProcName(DHCP6_NAME);
+ server.setConfigFile(config_file);
+ server.createPIDFile();
+
try {
// Initialize the server, e.g. establish control session
// Read a configuration file
LOG_INFO(dhcp6_logger, DHCP6_SHUTDOWN);
+ } catch (const isc::dhcp::DaemonPIDExists& ex) {
+ // First, we print the error on stderr (that should always work)
+ cerr << DHCP6_NAME << " already running? " << ex.what()
+ << endl;
+
+ // Let's also try to log it using logging system, but we're not
+ // sure if it's usable (the exception may have been thrown from
+ // the logger subsystem)
+ LOG_FATAL(dhcp6_logger, DHCP6_ALREADY_RUNNING)
+ .arg(DHCP6_NAME).arg(ex.what());
+ ret = EXIT_FAILURE;
} catch (const std::exception& ex) {
// First, we print the error on stderr (that should always work)
for shtest in $(SHTESTS) ; do \
echo Running test: $$shtest ; \
export KEA_LOCKFILE_DIR=$(abs_top_builddir); \
+ export KEA_PIDFILE_DIR=$(abs_top_builddir); \
${SHELL} $(abs_builddir)/$$shtest || exit ; \
done
test_finish 0
}
+server_pid_file_test "${CONFIG}" DHCP6_ALREADY_RUNNING
dynamic_reconfiguration_test
shutdown_test "dhcpv6.sigterm_test" 15
shutdown_test "dhcpv6.sigint_test" 2
::testing::InitGoogleTest(&argc, argv);
isc::log::initLogger();
+ setenv("KEA_PIDFILE_DIR", TEST_DATA_BUILDDIR, 1);
int result = RUN_ALL_TESTS();
return result;