Commit f5c89e78 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: added config param restart.pause

parent 667e7e81
......@@ -127,6 +127,7 @@ CONF_Add(const char *lval, const char *rval)
confUnsigned("hash.mlt", hash_mlt);
confUnsigned("nworkers", nworkers);
confUnsigned("restarts", restarts);
confUnsigned("restart.pause", restart_pause);
confUnsigned("thread.restarts", thread_restarts);
confUnsigned("monitor.interval", monitor_interval);
......@@ -209,6 +210,7 @@ CONF_Init(void)
config.mq_config_file[0] = '\0';
config.nworkers = 1;
config.restarts = 1;
config.restart_pause = 1;
config.thread_restarts = 1;
pw = getpwnam(DEFAULT_USER);
......@@ -261,6 +263,7 @@ CONF_Dump(void)
confdump("mq.config_file = %s", config.mq_config_file);
confdump("nworkers = %u", config.nworkers);
confdump("restarts = %u", config.restarts);
confdump("restart.pause = %u", config.restart_pause);
confdump("thread.restarts = %u", config.thread_restarts);
confdump("user = %s", config.user_name);
}
......@@ -22,7 +22,7 @@ CMD="../trackrdrd -D -f varnish.binlog -l - -d -c test.conf"
# the user running it
CKSUM=$( $CMD | sed -e 's/\(initializing\) \(.*\)/\1/' | sed -e 's/\(Running as\) \([a-zA-Z0-9]*\)$/\1/' | grep -v 'Not running as root' | cksum)
if [ "$CKSUM" != '1900415110 234158' ]; then
if [ "$CKSUM" != '2777461934 234191' ]; then
echo "ERROR: Regression test incorrect cksum: $CKSUM"
exit 1
fi
......
......@@ -46,6 +46,7 @@
#define DEFAULT_USER "nobody"
#define DEFAULT_PID_FILE "/var/run/trackrdrd.pid"
#define DEFAULT_RESTART_PAUSE 1
#define confdump(str,val) \
i += sprintf(verbose_buffer + i, str"\n", (val))
......@@ -84,6 +85,7 @@ getConfigContent(void)
confdump("mq.config_file = %s", config.mq_config_file);
confdump("nworkers = %u", config.nworkers);
confdump("restarts = %u", config.restarts);
confdump("restart.pause = %u", config.restart_pause);
confdump("thread.restarts = %u", config.thread_restarts);
confdump("user = %s", config.user_name);
return verbose_buffer;
......@@ -125,6 +127,7 @@ static char
"Default user name expected: \"%s\", but found: \"%s\"", DEFAULT_USER, config.user_name);
VMASSERT(!strcmp(DEFAULT_PID_FILE, config.pid_file),
"Default pid file name expected: \"%s\", but found: \"%s\"", DEFAULT_PID_FILE, config.user_name);
MASSERT(DEFAULT_RESTART_PAUSE == config.restart_pause);
return NULL;
}
......
......@@ -17,5 +17,6 @@ mq.module = /var/opt/varnish_tracking/lib/trackrdrd/libtrackrdr-activemq.so
mq.config_file = /etc/trackrdr-activemq.conf
nworkers = 20
restarts = 100
restart.pause = 1
thread.restarts = 100
user = root
......@@ -17,5 +17,6 @@ mq.module = /var/opt/varnish_tracking/lib/trackrdrd/libtrackrdr-activemq.so
mq.config_file = /etc/trackrdr-activemq.conf
nworkers = 2
restarts = 3
restart.pause = 2
thread.restarts = 4
user = nobody
......@@ -17,5 +17,6 @@ mq.module = /var/opt/varnish_tracking/lib/trackrdrd/libtrackrdr-activemq.so
mq.config_file = /etc/trackrdr-activemq.conf
nworkers = 1
restarts = 1
restart.pause = 0
thread.restarts = 1
user = root
......@@ -196,6 +196,11 @@ parent_main(pid_t child_pid, struct VSM_data *vd, int endless)
parent_shutdown(EXIT_FAILURE, 0);
}
if (config.restart_pause > 0) {
LOG_Log(LOG_INFO, "Pausing %u seconds before restarting child",
config.restart_pause);
TIM_sleep(config.restart_pause);
}
child_pid = child_restart(child_pid, vd, endless, 0);
restarts++;
}
......
......@@ -322,6 +322,7 @@ struct config {
char mq_config_file[BUFSIZ];
unsigned nworkers;
unsigned restarts;
unsigned restart_pause;
unsigned thread_restarts;
char user_name[BUFSIZ];
uid_t uid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment