Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Commit

Permalink
Send more logs to docker output
Browse files Browse the repository at this point in the history
  • Loading branch information
biskyt committed Apr 29, 2020
1 parent f1c4347 commit d93be22
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions web/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,26 @@ fi
echo "Starting opeyes apache process..."
echo "openeyes should now be available in your web browser on your chosen port."
echo ""
echo "*********************************************"
echo "** -= END OF STARTUP SCRIPT =- **"
echo "*********************************************"
# Send output of openeyeyes application log to stdout - for viewing with docker logs
[ ! -f $WROOT/protected/runtime/application.log ] && {
touch $WROOT/protected/runtime/application.log
chmod 664 $WROOT/protected/runtime/application.log
} | :
[ ! -f $WROOT/protected/runtime/portalexams.log ] && {
touch $WROOT/protected/runtime/portalexams.log
chmod 664 $WROOT/protected/runtime/portalexams.log
} | :
[ ! -f /var/log/php_errors.log ] && {
touch /var/log/php_errors.log
chmod 664 /var/log/php_errors.log
} | :
tail -n0 $WROOT/protected/runtime/application.log -F | awk '/^==> / {a=substr($0, 5, length-8); next} {print a"App Log:"$0}' &
tail -n0 $WROOT/protected/runtime/portalexams.log -F | awk '/^==> / {a=substr($0, 5, length-8); next} {print a"Portal Log:"$0}' &
tail -n0 /var/log/php_errors.log -F | awk '/^==> / {a=substr($0, 5, length-8); next} {print a"PHP Log:"$0}' &

## Send output of openeyeyes application log to stdout - for viewing with docker logs
if [ ! ${OUTPUT_APPLICATION_LOGS^^} != "FALSE" ]; then
declare -A logs
# [Key]value pairs of [file location] and 'name' for each log to output
logs=(["$WROOT/protected/runtime/application.log"]="OE" ["$WROOT/protected/runtime/portalexams.log"]="Portal" ["/var/log/php_errors.log"]="PHP Error" ["/var/log/apache2/access.log"]="Apache" ["/var/log/apache2/error.log"]="Apache Error")

for key in ${!logs[@]}; do

# if file does not exist, create it
if [ ! -f ${key} ]; then
touch ${key}
chmod 664 ${key}
fi

echo "Outputting ${key} to stdout as '${logs[${key}]}'"
# start tailing the log and continue
tail -n0 ${key} -F | awk '/^==> / {a=substr($0, 5, length-8); next} {print a"'"${logs[${key}]}"':"$0}' &
done
fi

# note - the ^^ converts to uppercase (,, can be used to convert to lowercase)
if [ ${OE_MODE^^} = "TEST" ]; then
Expand Down Expand Up @@ -312,4 +313,9 @@ if [ ${OE_MODE^^} = "TEST" ]; then
fi
fi

echo ""
echo "*********************************************"
echo "** -= END OF STARTUP SCRIPT =- **"
echo "*********************************************"

apachectl -DFOREGROUND

0 comments on commit d93be22

Please sign in to comment.