diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2019-09-09 20:05:36 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2019-09-09 20:05:36 +0300 |
commit | a6a01fd6355dde9ccade53cda4a946960d673af1 (patch) | |
tree | 7f2112de22c8021a46ffe780a51d5665124060b0 /.travis/track_status.sh | |
parent | Travis: run more scripts (diff) | |
download | vk-scripts-a6a01fd6355dde9ccade53cda4a946960d673af1.tar.gz vk-scripts-a6a01fd6355dde9ccade53cda4a946960d673af1.zip |
handle SIGINT in StatusTracker properly
Diffstat (limited to '.travis/track_status.sh')
-rwxr-xr-x | .travis/track_status.sh | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/.travis/track_status.sh b/.travis/track_status.sh index 3702676..0e3d2d8 100755 --- a/.travis/track_status.sh +++ b/.travis/track_status.sh @@ -2,18 +2,35 @@ set -o errexit -o nounset -o pipefail -main() { +track_status() { local log_path log_path="$( mktemp )" + echo "Log file path: $log_path" + + local rm_log_path + rm_log_path="$( printf -- 'rm -f -- %q' "$log_path" )" - nohup python3 -m bin.track_status egor.tensin > "$log_path" 2>&1 & + trap "$rm_log_path" RETURN + + echo 'Running track_status.py...' + python3 -m bin.track_status egor.tensin --log "$log_path" & local pid="$!" + echo "Its PID is $pid" + + local timeout=15 + echo "Sleeping for $timeout seconds..." + sleep "$timeout" - sleep 15 + echo 'Terminating track_status.py...' kill -SIGINT "$pid" + echo 'Waiting for track_status.py to terminate...' wait "$pid" cat "$log_path" } -main +main() { + track_status +} + +main "$@" |