mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
patches: add support for running sysrepo-plugind in the foreground
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
commit 6fc440089353d76a9b8cb7c480402ee911a1387d
|
||||
Author: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Tue Mar 28 10:37:53 2023 +0200
|
||||
|
||||
sysrepo-plugind: add support for running in foreground with syslog
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
|
||||
diff --git a/src/executables/sysrepo-plugind.c b/src/executables/sysrepo-plugind.c
|
||||
index bd584ed5..3079a855 100644
|
||||
--- a/src/executables/sysrepo-plugind.c
|
||||
+++ b/src/executables/sysrepo-plugind.c
|
||||
@@ -97,6 +97,7 @@ help_print(void)
|
||||
" Change verbosity to a level (none, error, warning, info, debug) or\n"
|
||||
" number (0, 1, 2, 3, 4).\n"
|
||||
" -d, --debug Debug mode - is not daemonized and logs to stderr instead of syslog.\n"
|
||||
+ " -n, --foreground Run in foreground and log to syslog.\n"
|
||||
" -P, --plugin-install <path>\n"
|
||||
" Install a sysrepo-plugind plugin. The plugin is simply copied\n"
|
||||
" to the designated plugin directory.\n"
|
||||
@@ -200,6 +201,8 @@ daemon_init(int debug, sr_log_level_t log_level)
|
||||
|
||||
if (debug) {
|
||||
handle_signals();
|
||||
+ if (debug < 0)
|
||||
+ goto done;
|
||||
sr_log_stderr(log_level);
|
||||
return;
|
||||
}
|
||||
@@ -240,6 +243,7 @@ daemon_init(int debug, sr_log_level_t log_level)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
+done:
|
||||
/* set verbosity */
|
||||
sr_log_syslog("sysrepo-plugind", log_level);
|
||||
}
|
||||
@@ -459,6 +463,7 @@ main(int argc, char **argv)
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{"verbosity", required_argument, NULL, 'v'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
+ {"foreground", no_argument, NULL, 'n'},
|
||||
{"plugin-install", required_argument, NULL, 'P'},
|
||||
{"pid-file", required_argument, NULL, 'p'},
|
||||
{"fatal-plugin-fail", no_argument, NULL, 'f'},
|
||||
@@ -467,7 +472,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* process options */
|
||||
opterr = 0;
|
||||
- while ((opt = getopt_long(argc, argv, "hVv:dP:p:f", options, NULL)) != -1) {
|
||||
+ while ((opt = getopt_long(argc, argv, "hVv:dnP:p:f", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
version_print();
|
||||
@@ -499,6 +504,9 @@ main(int argc, char **argv)
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
+ case 'n':
|
||||
+ debug = -1;
|
||||
+ break;
|
||||
case 'P':
|
||||
/* plugin-install */
|
||||
if (get_plugins_dir(&plugins_dir)) {
|
||||
Reference in New Issue
Block a user