Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
425
Issues
425
List
Boards
Labels
Service Desk
Milestones
Merge Requests
64
Merge Requests
64
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
1740704a
Commit
1740704a
authored
Aug 14, 2018
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gitlab1] pid file, signals support implemented for kea-netconf
parent
f1ebc54c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
5 deletions
+41
-5
src/bin/netconf/main.cc
src/bin/netconf/main.cc
+41
-5
No files found.
src/bin/netconf/main.cc
View file @
1740704a
...
...
@@ -10,6 +10,10 @@
#include <exceptions/exceptions.h>
#include <dhcpsrv/daemon.h>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <cstdio>
#include <signal.h>
#include <sysrepo-cpp/Session.h>
...
...
@@ -32,6 +36,32 @@ usage() {
exit
(
EXIT_FAILURE
);
}
/// @name Temporary code until isc::dhcp::Daemon is used.
///
/// @{
const
char
*
PID_FILENAME
=
"kea-netconf.test_config.pid"
;
volatile
bool
SHUTDOWN_FLAG
=
false
;
void
createPIDFile
(
int
pid
)
{
// This is not a real implemented. We will soon use the one coming
// from isc::dhcp::Daemon AFTER it's moved to libprocess.
ofstream
file
(
PID_FILENAME
,
ios
::
trunc
);
file
<<
pid
;
}
void
deletePIDFile
()
{
remove
(
PID_FILENAME
);
}
static
void
signal_handler
(
int
)
{
SHUTDOWN_FLAG
=
true
;
}
/// @}
int
main
(
int
argc
,
char
*
argv
[])
{
// The standard config file
...
...
@@ -70,10 +100,14 @@ main(int argc, char* argv[]) {
int
ret
=
EXIT_SUCCESS
;
try
{
// 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
// in the Kea configuration file.
//CfgMgr::instance().setDefaultLoggerName(KEA_NETCONF_LOGGER_NAME);
// Temporary code. This will be replaced with isc::dhcp::Daemon
// once it is migrated to libprocess. We DO NOT want to bring
// the whole libdhcpsrv into netconf.
createPIDFile
(
getpid
());
signal
(
SIGHUP
,
signal_handler
);
signal
(
SIGINT
,
signal_handler
);
signal
(
SIGTERM
,
signal_handler
);
// Initialize logging. If verbose, we'll use maximum verbosity.
bool
verbose_mode
=
true
;
...
...
@@ -86,7 +120,7 @@ main(int argc, char* argv[]) {
LOG_INFO
(
netconf_logger
,
NETCONF_STATED
).
arg
(
VERSION
);
// And run the main loop of the server.
while
(
true
)
{
while
(
!
SHUTDOWN_FLAG
)
{
cout
<<
"Dummy kea-netconf running. Press ctrl-c to terminate."
<<
endl
;
sleep
(
1
);
...
...
@@ -94,6 +128,8 @@ main(int argc, char* argv[]) {
LOG_INFO
(
netconf_logger
,
NETCONF_SHUTDOWN
);
deletePIDFile
();
}
catch
(
const
isc
::
Exception
&
ex
)
{
// First, we parint the error on stderr (that should always work)
cerr
<<
"ERROR:"
<<
ex
.
what
()
<<
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment