-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Reuse Docker container between reloads, closes #369 On my machine, this change reduces reload time from ~1.5s to ~400ms * Remove redundant `await`s * Add return type annotations to `Runtime#dispose()` implementations
- Loading branch information
Showing
6 changed files
with
157 additions
and
32 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
* | ||
!.gitignore | ||
!restart.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,40 @@ | ||
#!/usr/bin/env bash | ||
# Restarts a process on receiving SIGUSR1. | ||
# Usage: ./restart.sh <command> <...args> | ||
|
||
# Start process and record its PID | ||
"$@" & | ||
PID=$! | ||
echo "[*] Started $PID" | ||
|
||
# Trap SIGUSR1 to set $RECEIVED_USR1 to 1, then terminate $PID. | ||
# Setting $RECEIVED_USR1 will cause the process to be restarted. | ||
RECEIVED_USR1=0 | ||
trap 'RECEIVED_USR1=1 && kill -TERM $PID' USR1 | ||
|
||
# Trap SIGINT and SIGTERM to also terminate $PID for cleanup. | ||
# By not setting $RECEIVED_USR1, we ensure this script exits | ||
# when $PID exits. | ||
trap 'kill -TERM $PID' INT TERM | ||
|
||
while true | ||
do | ||
# Wait for the started process to exit | ||
wait $PID | ||
EXIT_CODE=$? | ||
|
||
# If the process exited for any reason other than this script | ||
# receiving SIGUSR1, exit the script with the same exit code. | ||
if [ $RECEIVED_USR1 -eq 0 ] | ||
then | ||
echo "[*] Exited with status $EXIT_CODE" | ||
exit $EXIT_CODE | ||
fi | ||
|
||
# Otherwise, if this script received SIGUSR1, reset the flag, | ||
# restart the process, and record its new PID. | ||
RECEIVED_USR1=0 | ||
"$@" & | ||
PID=$! | ||
echo "[*] Restarted $PID" | ||
done |
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
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