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}" ...@@ -28,11 +28,31 @@ CMD="${TRACKRDRD_BIN}"
CURL=/usr/bin/curl CURL=/usr/bin/curl
URL=http://localhost/ts-rcv?testSession=true URL=http://localhost/ts-rcv?testSession=true
START_RETRIES=5
if [ ! -e ${TRACKRDRD_BIN} ]; then if [ ! -e ${TRACKRDRD_BIN} ]; then
echo "${TRACKRDRD_BIN} not installed" echo "${TRACKRDRD_BIN} not installed"
fi fi
function start_trackrdrd { 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 ... " echo -n "Starting trackrdrd ... "
startproc -q ${CMD} startproc -q ${CMD}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -48,7 +68,7 @@ function stop_trackrdrd { ...@@ -48,7 +68,7 @@ function stop_trackrdrd {
killproc ${TRACKRDRD_BIN} killproc ${TRACKRDRD_BIN}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FAILED (killproc returned $?)" echo "FAILED (killproc returned $?)"
logger "trackrdrd start FAILED (killproc returned $?)" logger "trackrdrd stop FAILED (killproc returned $?)"
exit 1 exit 1
fi fi
${CURL} ${URL} >/dev/null 2&>1 ${CURL} ${URL} >/dev/null 2&>1
...@@ -74,11 +94,6 @@ function check_varnishd { ...@@ -74,11 +94,6 @@ function check_varnishd {
case "$1" in case "$1" in
start) start)
checkproc ${TRACKRDRD_BIN}
if [ $? -eq 0 ]; then
echo "trackrdrd already running"
exit 1
fi
check_varnishd check_varnishd
start_trackrdrd start_trackrdrd
exit 0 exit 0
...@@ -91,7 +106,6 @@ case "$1" in ...@@ -91,7 +106,6 @@ case "$1" in
check_varnishd check_varnishd
echo "Restarting trackrdrd" echo "Restarting trackrdrd"
stop_trackrdrd stop_trackrdrd
sleep 1
start_trackrdrd start_trackrdrd
sleep 1 sleep 1
getstatus_trackrdrd getstatus_trackrdrd
......
...@@ -40,6 +40,32 @@ ...@@ -40,6 +40,32 @@
static int run; 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 void
*MON_StatusThread(void *arg) *MON_StatusThread(void *arg)
{ {
...@@ -51,7 +77,9 @@ void ...@@ -51,7 +77,9 @@ void
LOG_Log(LOG_INFO, "Monitor thread running every %.2f secs", LOG_Log(LOG_INFO, "Monitor thread running every %.2f secs",
t.tv_sec + ((float) t.tv_nsec * 10e-9)); t.tv_sec + ((float) t.tv_nsec * 10e-9));
run = 1; run = 1;
pthread_cleanup_push(monitor_cleanup, arg);
while (run) { while (run) {
int err; int err;
if (nanosleep(&t, NULL) != 0) { if (nanosleep(&t, NULL) != 0) {
...@@ -68,20 +96,10 @@ void ...@@ -68,20 +96,10 @@ void
pthread_exit(&err); pthread_exit(&err);
} }
} }
LOG_Log(LOG_INFO, log_output();
"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();
} }
pthread_cleanup_pop(0);
LOG_Log0(LOG_INFO, "Monitoring thread exiting"); LOG_Log0(LOG_INFO, "Monitoring thread exiting");
pthread_exit((void *) NULL); pthread_exit((void *) NULL);
} }
...@@ -90,6 +108,7 @@ void ...@@ -90,6 +108,7 @@ void
MON_StatusShutdown(pthread_t monitor) MON_StatusShutdown(pthread_t monitor)
{ {
run = 0; run = 0;
AZ(pthread_cancel(monitor));
AZ(pthread_join(monitor, NULL)); 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