scripts: scripts-library.sh: Fix dstat background process command

The correct way to background the dstat process is by using
(dstat...&) which creates a grandchild process which is inherited by
the init process once the child dies. The existing code didn't do that
since it was creating a background process of a child process so in
the end the child process couldn't be killed by Ansible and the job was
timing out. The dstat process is normally being killed as part of the
post-run playbook. Moreover, the '3' file descriptor probably doesn't
make much sense so we simply redirect stdout and stderr to the logfile
and make sure we close the stdin one before going to the background.

Change-Id: I62d18c196b9bcd267f28f091af7761e7a514e652
(cherry picked from commit f6deb4f62b)
This commit is contained in:
Markos Chandras 2018-03-01 15:29:34 +00:00 committed by Markos Chandras (hwoarang)
parent ba77cee3e8
commit b12ee4b734

View File

@ -206,7 +206,8 @@ function run_dstat {
# https://stackoverflow.com/a/20338327 executing in ()& decouples the dstat
# process from scripts-library to prevent hung builds if dstat fails to exit
# for any reason.
(dstat -tcmsdn --top-cpu --top-mem --top-bio --nocolor --output /openstack/log/instance-info/dstat.csv 3 > /openstack/log/instance-info/dstat.log)&
(dstat -tcmsdn --top-cpu --top-mem --top-bio --nocolor --output /openstack/log/instance-info/dstat.csv \
< /dev/null > /openstack/log/instance-info/dstat.log 2>&1 &)
fi
}