ViaQ / watches-cli

:watch: CLI tool to pull statistics from Elasticsearch
Apache License 2.0
1 stars 1 forks source link

Flush stdout on signals TERM and INT #26

Closed lukas-vlcek closed 7 years ago

lukas-vlcek commented 7 years ago

Closes #25

lukas-vlcek commented 7 years ago

Here is how I tested this functionality. The following script runs watches for 10 seconds and get data from ES every second. However, the script is terminated after 5 seconds:

#!/bin/bash

cat /dev/null > test.log
watches cluster_health -l -d 10 -i 1 > test.log &
echo started $!
sleep 5
kill -s TERM $!
echo Number of lines in log life: `cat test.log | wc -l`

In the past the log file was empty, now we can use both TERM or INT kill signals and the log file contains 5 rows (which is expected):

$ ./run.sh 
+ cat /dev/null
+ echo started 39506
started 39506
+ sleep 5
+ watches cluster_health -l -d 10 -i 1
+ kill -s TERM 39506
++ cat test.log
++ wc -l
+ echo Number of lines in log life: 5
Number of lines in log life: 5
lukas-vlcek commented 7 years ago

@richm PTAL