|
4 | 4 |
|
5 | 5 | 1. [General Hints](#general) |
6 | 6 | 1. [Development / Editor Setup](#editors) |
7 | | - 1. [Visual Studio Code (vscode)](#vscode) |
8 | | -1. [Testing][#testing] |
| 7 | + 1. [Visual Studio Code (vscode)](#vscode) |
| 8 | +1. [Testing](#testing) |
9 | 9 | 1. [Using Buildkit](#buildkit) |
10 | 10 | 1. [Local HTTP(S) Caching Proxy](#caching) |
11 | 11 | 1. [Local S3 Server](#local-s3-server) |
| 12 | +1. [Stop on Suspend](#stop-on-suspend) |
12 | 13 |
|
13 | 14 | <a name="general"></a> |
14 | 15 | ## General |
@@ -138,3 +139,31 @@ Typical policy: |
138 | 139 |
|
139 | 140 | Then set the **build-arg** `AWS_S3_ENDPOINT_URL="http://172.17.0.1:9000"` |
140 | 141 | or as appropriate if you've changed the default docker network. |
| 142 | + |
| 143 | +<a name="stop-on-suspend"></a> |
| 144 | +## Stop on Suspend |
| 145 | + |
| 146 | +Maybe it's just me, but frequently I'll have issues when suspending with |
| 147 | +the container running (I guess its a CUDA issue), either a freeze on resume, |
| 148 | +or a stuck-forever defunct process. I found it useful to automatically stop |
| 149 | +the container / process on suspend. |
| 150 | + |
| 151 | +I'm running ArchLinux and set up a `systemd` suspend hook as described |
| 152 | +[here](https://wiki.archlinux.org/title/Power_management#Sleep_hooks), to |
| 153 | +call a script, which contains: |
| 154 | + |
| 155 | +```bash |
| 156 | +# Stop a matching docker container |
| 157 | +PID=`docker ps -qf ancestor=gadicc/diffusers-api` |
| 158 | +if [ ! -z $PID ] ; then |
| 159 | + echo "Stopping diffusers-api pid $PID" |
| 160 | + docker stop $PID |
| 161 | +fi |
| 162 | + |
| 163 | +# For a VSCode devcontainer, just kill the watchmedo process. |
| 164 | +PID=`docker ps -qf volume=/home/dragon/root-cache` |
| 165 | +if [ ! -z $PID ] ; then |
| 166 | + echo "Stopping watchmedo in container $PID" |
| 167 | + docker exec $PID /bin/bash -c 'kill `pidof -sx watchmedo`' |
| 168 | +fi |
| 169 | +``` |
0 commit comments