Always stop db container when start-db exits
This commit is contained in:
parent
13a2ee9736
commit
c47b99a8c1
1 changed files with 1 additions and 10 deletions
|
@ -11,20 +11,11 @@ in
|
||||||
(pkgs.writeScriptBin "start-db" ''
|
(pkgs.writeScriptBin "start-db" ''
|
||||||
#!${pkgs.zsh}/bin/zsh
|
#!${pkgs.zsh}/bin/zsh
|
||||||
|
|
||||||
_sighandler() {
|
trap "docker stop dodona-db" 0
|
||||||
docker stop dodona-db
|
|
||||||
}
|
|
||||||
|
|
||||||
trap _sighandler SIGINT
|
|
||||||
trap _sighandler SIGTERM
|
|
||||||
trap _sighandler SIGHUP
|
|
||||||
|
|
||||||
docker run --name dodona-db -p 3306:3306 --rm -v $(git rev-parse --show-toplevel)/tmp/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=dodona mariadb:latest &
|
docker run --name dodona-db -p 3306:3306 --rm -v $(git rev-parse --show-toplevel)/tmp/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=dodona mariadb:latest &
|
||||||
|
|
||||||
child=$!
|
child=$!
|
||||||
wait $child
|
wait $child
|
||||||
# We wait two times, because the first wait exits when the process receives a signal. The process might have finished though, so we ignore errors.
|
|
||||||
wait $child 2>/dev/null
|
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue