-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #486 from joyent/fanhattan-reopen
config: Introduce logging to file w/ log file re-open on SIGUSR1
- Loading branch information
Showing
10 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ testImport: | |
version: v1.1.4 | ||
subpackages: | ||
- assert | ||
- package: github.com/client9/reopen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
integration_tests/fixtures/app/containerpilot-with-file-log.json5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
consul: "consul:8500", | ||
logging: { | ||
level: "DEBUG", | ||
format: "text", | ||
output: "/tmp/containerpilot.log" | ||
}, | ||
jobs: [ | ||
{ | ||
name: "app", | ||
exec: "echo 'hello world!'", | ||
when: { | ||
interval: 1 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
app: | ||
image: "cpfix_app" | ||
mem_limit: 128m | ||
volumes: | ||
- './test_reopen.sh:/tmp/test_reopen.sh' | ||
environment: | ||
# needs to be in the container already or we'll potentially | ||
# error when we try to rewrite it; update in the future | ||
# with an env var change to the args instead | ||
- CONTAINERPILOT=/etc/containerpilot-with-file-log.json5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
function finish { | ||
result=$? | ||
if [[ "$result" -ne 0 ]]; then docker logs "$app" | tee app.log; fi | ||
exit $result | ||
} | ||
trap finish EXIT | ||
|
||
# start up app | ||
docker-compose up -d app | ||
app=$(docker-compose ps -q app) | ||
|
||
docker exec -i $app /tmp/test_reopen.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
CONTAINERPILOT_LOGFILE="/tmp/containerpilot.log" | ||
CONTAINERPILOT_ROTATEDLOGFILE="/tmp/containerpilot.log.1" | ||
|
||
sleep 2 | ||
logs=`cat $CONTAINERPILOT_LOGFILE` | ||
nb_lines=`cat $CONTAINERPILOT_LOGFILE | wc -l` | ||
if [ ! -f $CONTAINERPILOT_LOGFILE ] || [[ $logs != *"hello world"* ]]; then | ||
exit 1 | ||
fi | ||
|
||
#rotate logs | ||
mv $CONTAINERPILOT_LOGFILE $CONTAINERPILOT_ROTATEDLOGFILE | ||
|
||
sleep 2 | ||
nb_lines_rotated=`cat $CONTAINERPILOT_ROTATEDLOGFILE | wc -l` | ||
if (( $nb_lines_rotated <= $nb_lines )); then | ||
exit 1 | ||
fi | ||
|
||
#signal containerpilot to reopen file | ||
kill -SIGUSR1 1 | ||
|
||
sleep 2 | ||
logs=`cat $CONTAINERPILOT_LOGFILE` | ||
if [ ! -f $CONTAINERPILOT_LOGFILE ] || [[ $logs != *"hello world"* ]]; then | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters