Package: nutcracker / 0.5.0+dfsg-2

sysconfdir Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From: Faidon Liambotis <paravoid@debian.org>
Date: Sat, 11 Feb 2023 22:28:01 +0200
Subject: Use sysconfdir & localstatedir for conf/pid/logs

Forwarded: https://github.com/twitter/twemproxy/pull/123
Last-Update: 2016-12-17
---
 src/Makefile.am | 7 +++++++
 src/nc.c        | 9 +++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index e32be10..ab23407 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,11 @@
 MAINTAINERCLEANFILES = Makefile.in
+BUILT_SOURCES = cfg-options.h
+CLEANFILES = cfg-options.h
+
+cfg-options.h: Makefile
+	$(AM_V_GEN)echo '#define NC_CONF_PATH "$(sysconfdir)/nutcracker/nutcracker.yml"' >$@
+	@echo '#define NC_LOG_PATH "$(localstatedir)/log/nutcracker/nutcracker.log"' >>$@
+	@echo '#define NC_PID_FILE "/run/nutcracker/nutcracker.pid"' >>$@
 
 AM_CPPFLAGS =
 if !OS_SOLARIS
diff --git a/src/nc.c b/src/nc.c
index 0d606ba..030ae29 100644
--- a/src/nc.c
+++ b/src/nc.c
@@ -28,19 +28,16 @@
 #include <nc_conf.h>
 #include <nc_signal.h>
 
-#define NC_CONF_PATH        "conf/nutcracker.yml"
+#include "cfg-options.h"
 
 #define NC_LOG_DEFAULT      LOG_NOTICE
 #define NC_LOG_MIN          LOG_EMERG
 #define NC_LOG_MAX          LOG_PVERB
-#define NC_LOG_PATH         NULL
 
 #define NC_STATS_PORT       STATS_PORT
 #define NC_STATS_ADDR       STATS_ADDR
 #define NC_STATS_INTERVAL   STATS_INTERVAL
 
-#define NC_PID_FILE         NULL
-
 #define NC_MBUF_SIZE        MBUF_SIZE
 #define NC_MBUF_MIN_SIZE    MBUF_MIN_SIZE
 #define NC_MBUF_MAX_SIZE    MBUF_MAX_SIZE
@@ -298,7 +295,7 @@ nc_set_default_options(struct instance *nci)
     nci->mbuf_chunk_size = NC_MBUF_SIZE;
 
     nci->pid = (pid_t)-1;
-    nci->pid_filename = NULL;
+    nci->pid_filename = NC_PID_FILE;
     nci->pidfile = 0;
 }
 
@@ -488,7 +485,7 @@ nc_pre_run(struct instance *nci)
         return status;
     }
 
-    if (nci->pid_filename) {
+    if (daemonize && nci->pid_filename) {
         status = nc_create_pidfile(nci);
         if (status != NC_OK) {
             return status;