-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add signal-handling ENTRYPOINT, cancel on QUIT
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,5 +61,6 @@ ENV [email protected] | |
VOLUME /code | ||
WORKDIR /code | ||
|
||
ENTRYPOINT ["/bin/restyler"] | ||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["--help"] |
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,32 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
docker build --tag restyled/restyler:test . | ||
|
||
export AWS_PROFILE=restyled | ||
|
||
echo "Launching Restyler" | ||
(restyled promote --image restyled/restyler:test stable |& ts >/tmp/run.log) & | ||
pid=$! | ||
echo "PID $pid" | ||
|
||
cid= | ||
|
||
echo "Waiting for Container" | ||
while [ -z "$cid" ]; do | ||
sleep 1 | ||
cid=$(docker ps | awk '/restyled\/restyler:test/ { print $1 }') | ||
done | ||
echo "Container Id: $cid" | ||
echo "Letting run..." | ||
sleep 15 | ||
|
||
echo "Sending SIGQUIT..." | ||
docker kill --signal SIGQUIT "$cid" | ||
# echo "Sending SIGSTOP..." | ||
# docker kill --signal SIGSTOP "$cid" | ||
# echo "Sending USR1..." | ||
# docker kill --signal USR1 "$cid" | ||
|
||
wait "$pid" | ||
echo "Restyler stopped." |
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/sh | ||
: "${RESTYLER_CANCEL_SIGNAL:=QUIT}" | ||
|
||
for signal in $(kill -l); do | ||
if [ "$signal" != "$RESTYLER_CANCEL_SIGNAL" ]; then | ||
# Best-effort forward all signals we don't handle | ||
trap 'kill -'"$signal"' "$restyler_pid" 2>/dev/null' "$signal" | ||
fi | ||
done | ||
|
||
trap 'echo "Build canceled."; exit 0' "$RESTYLER_CANCEL_SIGNAL" | ||
|
||
/bin/restyler "$@" & | ||
restyler_pid=$! | ||
wait "$restyler_pid" |