Skip to content

Commit d5f2668

Browse files
committed
chore(CONTRIBUTING): add notes about autokill on suspend
1 parent 2babd53 commit d5f2668

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
1. [General Hints](#general)
66
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)
99
1. [Using Buildkit](#buildkit)
1010
1. [Local HTTP(S) Caching Proxy](#caching)
1111
1. [Local S3 Server](#local-s3-server)
12+
1. [Stop on Suspend](#stop-on-suspend)
1213

1314
<a name="general"></a>
1415
## General
@@ -138,3 +139,31 @@ Typical policy:
138139

139140
Then set the **build-arg** `AWS_S3_ENDPOINT_URL="http://172.17.0.1:9000"`
140141
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

Comments
 (0)