pgqd: Add switch to show template config.
authorMarko Kreen <markokr@gmail.com>
Fri, 12 Mar 2010 12:16:07 +0000 (14:16 +0200)
committerMarko Kreen <markokr@gmail.com>
Fri, 12 Mar 2010 12:16:07 +0000 (14:16 +0200)
sql/ticker/Makefile
sql/ticker/pgqd.c
sql/ticker/pgqd.ini

index 9b9591bf2c040151eb9d395b8a1272d3b908e8ab..b88d0280e66ce21e811ad48e90f287ac2ab54005 100644 (file)
@@ -35,6 +35,10 @@ $(OBJS): $(HDRS)
 %.o: $(USUAL_DIR)/usual/%.c $(USUAL_HDRS)
        $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c -o $@ $<
 
+pgqd.o: pgqd.ini.h
+pgqd.ini.h: pgqd.ini
+       sed -e 's/.*/"&\\n"/' $< > $@
+
 install: all
        mkdir -p '$(DESTDIR)$(bindir)'
        $(BININSTALL) -m 755 pgqd$(X) '$(DESTDIR)$(bindir)/pgqd'
@@ -42,7 +46,7 @@ install: all
        $(INSTALL) -m 644 pgqd.ini '$(DESTDIR)$(docdir)/conf/pgqd.ini.templ'
 
 clean:
-       rm -f $(PROGRAM) $(OBJS)
+       rm -f $(PROGRAM) $(OBJS) pgqd.ini.h
 
 tags:
        ctags *.[ch] ../../lib/usual/*.[ch]
index ab1ae83cd33b8cc2e1f8268880e7a52ff8a7ea4e..f175b09b3ab33bddf3508240e26d3af9b90e91e2 100644 (file)
@@ -15,13 +15,18 @@ static void recheck_dbs(void);
 static const char *usage_str =
 "usage: pgq-ticker [switches] config.file\n"
 "Switches:\n"
-"  -H        Show help\n"
 "  -v        Increase verbosity\n"
 "  -q        No output to console\n"
-"  -V        Show version\n"
 "  -d        Daemonize\n"
+"  -H        Show help\n"
+"  -V        Show version\n"
+" --ini      Show sample config file\n"
 "";
 
+static const char *sample_ini =
+#include "pgqd.ini.h"
+;
+
 struct Config cf;
 
 static struct PgSocket *db_template;
@@ -84,7 +89,7 @@ static void handle_sigint(int sock, short flags, void *arg)
 
 static void handle_sighup(int sock, short flags, void *arg)
 {
-       log_info("Got SIGHUP re-reading config");
+       log_info("Got SIGHUP, re-reading config");
        load_config(true);
        recheck_dbs();
 }
@@ -266,6 +271,13 @@ int main(int argc, char *argv[])
        int c;
        bool daemon = false;
 
+       for (c = 1; c < argc; c++) {
+               if (!strcmp(argv[c], "--ini")) {
+                       printf("%s", sample_ini);
+                       exit(0);
+               }
+       }
+
        while ((c = getopt(argc, argv, "dqvhV")) != -1) {
                switch (c) {
                case 'd':
index 28e0864a111b84f8dc4cc287cc9a4d1e12e53934..f0c1809db0a7670da0fa58a4c8c0d4af07cc89fe 100644 (file)
@@ -1,32 +1,36 @@
 [pgqd]
 
 # where to log
-logfile = my.log
+logfile = 
 
 # pidfile
-pidfile = my.pid
+pidfile = 
 
-# how often to check for new databases
-check_period = 60
-
-# how often to flush retry queue
-retry_period = 15
-
-# how often to do maintentance
-maint_period = 120
-
-# how often to run ticker
-ticker_period = 0.5
+## optional parameters ##
 
 # libpq connect string without dbname=
-base_connstr = host=127.0.0.1
+#base_connstr =
 
 # startup db to query other databases
-initial_database = template1
+#initial_database = template1
 
-# limit ticker to specific databases (does not work)
-database_list =
+# limit ticker to specific databases
+#database_list =
 
 # log into syslog
-syslog = 0
+#syslog = 0
+
+## optional timeouts ##
+
+# how often to check for new databases
+#check_period = 60
+
+# how often to flush retry queue
+#retry_period = 30
+
+# how often to do maintentance
+#maint_period = 120
+
+# how often to run ticker
+#ticker_period = 1