Skip to content

Commit

Permalink
Implemented logfiles via named pipes
Browse files Browse the repository at this point in the history
Related #9
  • Loading branch information
mblaschke committed Oct 15, 2015
1 parent 9994cd2 commit a8f5c7c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docker/main/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ else
bash /opt/docker/bin/provision.sh entrypoint > /dev/null
fi

function createNamedPipe() {
rm --force -- "$1"
mknod "$1" p
}


#############################
## COMMAND
#############################
Expand All @@ -18,6 +24,12 @@ case "$1" in

## Supervisord (start daemons)
supervisord)

# Create named pipes for direct log output
createNamedPipe /tmp/php.slow.log
createNamedPipe /tmp/php.error.log
createNamedPipe /tmp/php.access.log

## Register IP
ETH0_IP=$(hostname -i)
mkdir -p /data/dns/
Expand Down
16 changes: 15 additions & 1 deletion docker/main/bin/logwatch.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#!/usr/bin/env bash

trap 'echo sigterm ; exit' SIGTERM
trap 'echo sigkill ; exit' SIGKILL

set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
set -o errexit ## set -e : exit the script if any statement returns a non-true return value

tail -F --quiet $2 | sed --unbuffered -e "s/^/\[$1\] /"
LOG_FACILITY="$1"
LOG_FILE="$2"

# Create pipe
if [ -f "${LOG_FILE}" ]; then
mknod "${LOG_FILE}" p
fi

# Output content
while true; do
sed --unbuffered -e "s/^/\[${LOG_FACILITY}\] /" < "${LOG_FILE}"
done

0 comments on commit a8f5c7c

Please sign in to comment.