Commit f92a6328 authored by Geoff Simmons's avatar Geoff Simmons

trackrdrd: shutdown cancels the monitoring threads (no need to wait for it)

           init script start checks if trackrdrd is running, waits for stop
parent 5f12fd96
......@@ -28,11 +28,31 @@ CMD="${TRACKRDRD_BIN}"
CURL=/usr/bin/curl
URL=http://localhost/ts-rcv?testSession=true
START_RETRIES=5
if [ ! -e ${TRACKRDRD_BIN} ]; then
echo "${TRACKRDRD_BIN} not installed"
fi
function start_trackrdrd {
START_CHECKS=0
echo -n "Checking if trackrdrd is running ..."
while [ ${START_CHECKS} -lt ${START_RETRIES} ]; do
checkproc ${TRACKRDRD_BIN}
if [ $? -ne 0 ]; then
break
fi
echo -n "."
START_CHECKS=$(( $START_CHECKS + 1 ))
sleep 1
continue
done
if [ ${START_CHECKS} -eq ${START_RETRIES} ]; then
echo " trackrdrd still running, giving up"
logger "trackrdrd still running, start FAILED"
exit 1
fi
echo ""
echo -n "Starting trackrdrd ... "
startproc -q ${CMD}
if [ $? -ne 0 ]; then
......@@ -48,7 +68,7 @@ function stop_trackrdrd {
killproc ${TRACKRDRD_BIN}
if [ $? -ne 0 ]; then
echo "FAILED (killproc returned $?)"
logger "trackrdrd start FAILED (killproc returned $?)"
logger "trackrdrd stop FAILED (killproc returned $?)"
exit 1
fi
${CURL} ${URL} >/dev/null 2&>1
......@@ -74,11 +94,6 @@ function check_varnishd {
case "$1" in
start)
checkproc ${TRACKRDRD_BIN}
if [ $? -eq 0 ]; then
echo "trackrdrd already running"
exit 1
fi
check_varnishd
start_trackrdrd
exit 0
......@@ -91,7 +106,6 @@ case "$1" in
check_varnishd
echo "Restarting trackrdrd"
stop_trackrdrd
sleep 1
start_trackrdrd
sleep 1
getstatus_trackrdrd
......
......@@ -40,6 +40,32 @@
static int run;
static void
log_output(void)
{
LOG_Log(LOG_INFO,
"Data table: len=%u collisions=%u insert_probes=%u find_probes=%u "
"open=%u done=%u load=%.2f len_overflows=%u data_overflows=%u "
"occ_hi=%u seen=%u submitted=%u nodata=%u sent=%u failed=%u "
"wait_qfull=%u data_hi=%u",
tbl.len, tbl.collisions, tbl.insert_probes, tbl.find_probes,
tbl.open, tbl.done, 100.0 * ((float) tbl.open + tbl.done) / tbl.len,
tbl.len_overflows, tbl.data_overflows, tbl.occ_hi, tbl.seen,
tbl.submitted, tbl.nodata, tbl.sent, tbl.failed, tbl.wait_qfull,
tbl.data_hi);
if (config.monitor_workers)
WRK_Stats();
}
static void
monitor_cleanup(void *arg)
{
(void) arg;
log_output();
LOG_Log0(LOG_INFO, "Monitoring thread exiting");
}
void
*MON_StatusThread(void *arg)
{
......@@ -52,6 +78,8 @@ void
t.tv_sec + ((float) t.tv_nsec * 10e-9));
run = 1;
pthread_cleanup_push(monitor_cleanup, arg);
while (run) {
int err;
if (nanosleep(&t, NULL) != 0) {
......@@ -68,20 +96,10 @@ void
pthread_exit(&err);
}
}
LOG_Log(LOG_INFO,
"Data table: len=%u collisions=%u insert_probes=%u find_probes=%u "
"open=%u done=%u load=%.2f len_overflows=%u data_overflows=%u "
"occ_hi=%u seen=%u submitted=%u nodata=%u sent=%u failed=%u "
"wait_qfull=%u data_hi=%u",
tbl.len, tbl.collisions, tbl.insert_probes, tbl.find_probes,
tbl.open, tbl.done, 100.0 * ((float) tbl.open + tbl.done) / tbl.len,
tbl.len_overflows, tbl.data_overflows, tbl.occ_hi, tbl.seen,
tbl.submitted, tbl.nodata, tbl.sent, tbl.failed, tbl.wait_qfull,
tbl.data_hi);
if (config.monitor_workers)
WRK_Stats();
log_output();
}
pthread_cleanup_pop(0);
LOG_Log0(LOG_INFO, "Monitoring thread exiting");
pthread_exit((void *) NULL);
}
......@@ -90,6 +108,7 @@ void
MON_StatusShutdown(pthread_t monitor)
{
run = 0;
AZ(pthread_cancel(monitor));
AZ(pthread_join(monitor, NULL));
}
......
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