Kea: main.cc Source File

| Kea 3.2.0-git

d2/main.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8#include <d2/d2_controller.h>
9#include <d2srv/d2_log.h>
10#include <exceptions/exceptions.h>
11#include <log/logger_manager.h>
12#include <log/logger_support.h>
13#include <util/filesystem.h>
14
15#include <iostream>
16
17using namespace isc::d2;
18using namespace isc::process;
19using namespace std;
20
26 int main(int argc, char* argv[]) {
27 isc::util::file::setUmask();
28
29 int ret = EXIT_SUCCESS;
30
31 // Launch the controller passing in command line arguments.
32 // Exit program with the controller's return code.
33 try {
34 // Instantiate/fetch the DHCP-DDNS application controller singleton.
35 DControllerBasePtr& controller = D2Controller::instance();
36
37 // 'false' value disables test mode.
38 ret = controller->launch(argc, argv, false);
39 } catch (const VersionMessage& ex) {
40 std::string msg(ex.what());
41 if (!msg.empty()) {
42 std::cout << msg << std::endl;
43 }
44 } catch (const InvalidUsage& ex) {
45 std::string msg(ex.what());
46 if (!msg.empty()) {
47 std::cerr << msg << std::endl;
48 }
49 ret = EXIT_FAILURE;
50 } catch (const std::exception& ex) {
51 std::cerr << "Service failed: " << ex.what() << std::endl;
52 ret = EXIT_FAILURE;
53 } catch (...) {
54 std::cerr << "Service failed" << std::endl;
55 ret = EXIT_FAILURE;
56 }
57
58 D2Controller::instance().reset();
59
60 return (ret);
61}
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::d2::D2Controller::instance
static process::DControllerBasePtr & instance()
Static singleton instance method.
Definition d2_controller.cc:36
isc::process::InvalidUsage
Exception thrown when the command line is invalid.
Definition d_controller.h:30
isc::process::VersionMessage
Exception used to convey version info upwards.
Definition d_controller.h:41
main
int main(int argc, char *argv[])
This file contains entry point (main() function) for standard DHCP-DDNS process, kea-dhcp-ddns,...
Definition d2/main.cc:26
d2_controller.h
d2_log.h
exceptions.h
filesystem.h
logger_manager.h
logger_support.h
Logging initialization functions.
isc::d2
Definition check_exists_add.cc:19
isc::process
Definition cb_ctl_base.h:22
isc::process::DControllerBasePtr
boost::shared_ptr< DControllerBase > DControllerBasePtr
Definition d_controller.h:78
isc::util::file::setUmask
void setUmask()
Set umask (at least 0027 i.e. no group write and no other access).
Definition filesystem.cc:98