From 897266c35d343dfef3640bfd8db7831ded5aee77 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 12 Mar 2010 14:16:07 +0200 Subject: [PATCH] pgqd: Add switch to show template config. --- sql/ticker/Makefile | 6 +++++- sql/ticker/pgqd.c | 18 +++++++++++++++--- sql/ticker/pgqd.ini | 40 ++++++++++++++++++++++------------------ 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/sql/ticker/Makefile b/sql/ticker/Makefile index 9b9591bf..b88d0280 100644 --- a/sql/ticker/Makefile +++ b/sql/ticker/Makefile @@ -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] diff --git a/sql/ticker/pgqd.c b/sql/ticker/pgqd.c index ab1ae83c..f175b09b 100644 --- a/sql/ticker/pgqd.c +++ b/sql/ticker/pgqd.c @@ -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': diff --git a/sql/ticker/pgqd.ini b/sql/ticker/pgqd.ini index 28e0864a..f0c1809d 100644 --- a/sql/ticker/pgqd.ini +++ b/sql/ticker/pgqd.ini @@ -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 -- 2.39.5