File: sysconfdir

package info (click to toggle)
nutcracker 0.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 1,388 kB
  • ctags: 1,493
  • sloc: ansic: 14,328; python: 1,147; sh: 854; makefile: 105
file content (60 lines) | stat: -rw-r--r-- 1,754 bytes parent folder | 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
Description: Use sysconfdir & localstatedir for conf/pid/logs
Author: Faidon Liambotis <paravoid@debian.org>
Forwarded: https://github.com/twitter/twemproxy/pull/123
Last-Update: 2016-12-17

--- 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
--- 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->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;