Skip to content

Commit

Permalink
better wait for collectd exit before graphs1090 writeback (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf authored Apr 10, 2024
1 parent 56c4e97 commit 5106c77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 70 deletions.
9 changes: 6 additions & 3 deletions rootfs/etc/s6-overlay/scripts/collectd
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ done
/usr/sbin/collectd -t -T -f -C /etc/collectd/collectd.conf > /dev/null 2>&1


trap 'echo "sending SIGTERM to collectd";pkill collectd' SIGTERM SIGINT SIGHUP SIGQUIT
# pkill -P $$ will only kill children of the script, not the script itself
trap 'pkill -P $$' SIGTERM SIGINT SIGHUP SIGQUIT
# for this scheme to work, the program is started in the background

# background execution + wait is necessary for trap to work -.-
#shellcheck disable=SC2016
s6wrap --quiet --prepend=collectd --timestamps --args /usr/sbin/collectd -C /etc/collectd/collectd.conf -f &
wait || true

# the first wait exits due to the signal which is trapped, the 2nd wait actually waits for collectd to exit
wait || wait || true



Expand Down
69 changes: 2 additions & 67 deletions rootfs/tar1090-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,72 +363,7 @@ do
done < <(echo "$instances")


if [[ $lighttpd == yes ]]; then
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep -i duplicate >/dev/null; then
mv -f /etc/lighttpd/conf-available/89-dump1090-fa.conf.dpkg-dist /etc/lighttpd/conf-available/89-dump1090-fa.conf &>/dev/null || true
fi

if ! grep -qs -E -e '^[^#]*"mod_alias"' /etc/lighttpd/lighttpd.conf /etc/lighttp/conf-enabled/* /etc/lighttpd/external.conf; then
echo 'server.modules += ( "mod_alias" )' > /etc/lighttpd/conf-available/07-mod_alias.conf
ln -s -f /etc/lighttpd/conf-available/07-mod_alias.conf /etc/lighttpd/conf-enabled/07-mod_alias.conf
else
rm -f /etc/lighttpd/conf-enabled/07-mod_alias.conf
fi

rm -f /etc/lighttpd/conf-available/87-mod_setenv.conf /etc/lighttpd/conf-enabled/87-mod_setenv.conf
while read -r FILE; do
sed -i -e 's/^server.modules.*mod_setenv.*/#\0/' "$FILE"
sed -i -e 's/^server.stat-cache-engine.*disable.*/#\0/' "$FILE"
done < <(find /etc/lighttpd/conf-available/* | grep -v setenv)

# add mod_setenv to lighttpd modules, check if it's one too much
echo 'server.modules += ( "mod_setenv" )' > /etc/lighttpd/conf-available/07-mod_setenv.conf
echo 'server.stat-cache-engine = "disable"' > /etc/lighttpd/conf-available/47-stat-cache.conf

ln -s -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
ln -s -f /etc/lighttpd/conf-available/47-stat-cache.conf /etc/lighttpd/conf-enabled/47-stat-cache.conf

if (( $(cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.stat-cache-engine *\= *"disable")') > 1 )); then
rm -f /etc/lighttpd/conf-enabled/47-stat-cache.conf
fi
if (( $(cat /etc/lighttpd/conf-enabled/* | grep -c -E -e '^server.modules.?\+=.?\(.?"mod_setenv".?\)') > 1 )); then
rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
fi

if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep mod_setenv >/dev/null; then
rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
fi
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep stat-cache >/dev/null; then
rm -f /etc/lighttpd/conf-enabled/47-stat-cache.conf
fi

#lighttpd -tt -f /etc/lighttpd/lighttpd.conf && echo success || true
if lighttpd -tt -f /etc/lighttpd/lighttpd.conf 2>&1 | grep mod_setenv >/dev/null
then
rm -f /etc/lighttpd/conf-available/07-mod_setenv.conf /etc/lighttpd/conf-enabled/07-mod_setenv.conf
fi
#lighttpd -tt -f /etc/lighttpd/lighttpd.conf && echo success || true
if ! lighttpd -tt -f /etc/lighttpd/lighttpd.conf &>/dev/null; then
echo ----------------
echo "Lighttpd error, tar1090 will probably not work correctly:"
lighttpd -tt -f /etc/lighttpd/lighttpd.conf
fi

if grep -qs -e '^compress.cache-dir' /etc/lighttpd/lighttpd.conf; then
echo -----
echo "Disabling compress.cache-dir in /etc/lighttpd/lighttpd.conf due to often causing full disk issues as there is no automatic cleanup mechanism. Add a leading space to the compress.cache-dir line if you don't want tar1090 to mess with it in the future."
echo -----
sed -i -e 's$^compress.cache-dir.*$#\0 # disabled by tar1090, often causes full disk due to not having a cleanup mechanism$' /etc/lighttpd/lighttpd.conf
elif ! grep -qs -e 'disabled by tar1090' /etc/lighttpd/lighttpd.conf; then
sed -i -e 's$^compress.cache-dir.*$# CAUTION, enabling cache-dir and filetype json will cause full disk when using tar1090\n\0$' /etc/lighttpd/lighttpd.conf
fi
if grep -qs -e '^deflate.cache-dir' /etc/lighttpd/lighttpd.conf; then
echo -----
echo "Disabling deflate.cache-dir in /etc/lighttpd/lighttpd.conf due to often causing full disk issues as there is no automatic cleanup mechanism. Add a leading space to the deflate.cache-dir line if you don't want tar1090 to mess with it in the future."
echo -----
sed -i -e 's$^deflate.cache-dir.*$#\0 # disabled by tar1090, often causes full disk due to not having a cleanup mechanism$' /etc/lighttpd/lighttpd.conf
elif ! grep -qs -e 'disabled by tar1090' /etc/lighttpd/lighttpd.conf; then
sed -i -e 's$^deflate.cache-dir.*$# CAUTION, enabling cache-dir and filetype json will cause full disk when using tar1090\n\0$' /etc/lighttpd/lighttpd.conf
fi
if [[ $lighttpd == yes ]] || [[ $nginx == yes ]]; then
true
fi

0 comments on commit 5106c77

Please sign in to comment.