-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker.conf
57 lines (49 loc) · 1.57 KB
/
docker.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# This is the derby-site docker process upstart script
# Should be copied to /etc/init/derbyjs/component-examples.conf
start on filesystem and started docker
stop on runlevel [!2345]
kill timeout 20
respawn
respawn limit 5 5
umask 022
script
SERVICE=$(basename $UPSTART_JOB)
CONTAINER=$SERVICE
IMAGE="derbyjs/${CONTAINER}"
echo "[$(date)] - $SERVICE starting"
# Sometimes the process exits without removing the docker image. We can't
# create a new Docker image with the same name, so cleanup any existing images
# with this container's name first
if docker ps -a | grep -q $CONTAINER; then
echo 'Removing docker image'
docker rm $CONTAINER || true
fi
echo "Running $CONTAINER $IMAGE (build $SHA)"
exec docker run \
--name $CONTAINER \
-p "3330:3330" \
-h "${HOSTNAME}-${CONTAINER}" \
-v "/var/log/upstart:/var/log/upstart" \
--link mongo:mongo \
--link redis:redis \
--rm \
$IMAGE
end script
post-stop script
SERVICE=$(basename $UPSTART_JOB)
CONTAINER=$SERVICE
IMAGE="derbyjs/${CONTAINER}"
echo "[$(date)] - $SERVICE starting"
# If the kill timeout expires, the process is killed - but the docker client
# process that gets killed isn't the actual image process, so we need to make
# sure the docker image is actually stopped.
if docker ps | grep -q $CONTAINER; then
echo 'Killing zombie docker container'
docker stop -t 2 $CONTAINER || true
docker wait $CONTAINER || true
fi
if docker ps -a | grep -q $CONTAINER; then
echo 'Removing docker image'
docker rm $CONTAINER || true
fi
end script