Skip to content

Commit

Permalink
Revert "[DEL] docker cron instance [DEVOPS-47]"
Browse files Browse the repository at this point in the history
  • Loading branch information
duchenean authored Jan 17, 2024
1 parent f8525cd commit 2136b4d
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 15 deletions.
20 changes: 14 additions & 6 deletions docker-dev.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[buildout]
parts +=
instance
instance-cron
parts -=
instance2
instance3
Expand All @@ -22,12 +23,6 @@ zope-conf-additional =
bind 0.0.0.0:${port:instance1-monitor}
</product-config>
${zope-conf:additional}
<clock-server>
method /${port:plone-path}/@@cron-tick
period 3600
user admin
password ${port:admin-password}
</clock-server>
${zope-conf:zamqp}
environment-vars -=
OO_PORT ${port:oo-port}
Expand All @@ -43,6 +38,19 @@ blob-storage = /data/blobstorage
environment-vars =
ZC_ASYNC_UUID /data/async-uuid.txt

[instance-cron]
<= instance
http-address = 8087
zope-conf-additional =
${zope-conf:additional}
<clock-server>
method /${port:plone-path}/@@cron-tick
period 3600
user admin
password ${port:admin-password}
</clock-server>
${zope-conf:zamqp}

environment-vars += ${bigbang:environment-vars}

[instance-debug]
Expand Down
67 changes: 61 additions & 6 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ services:
mem_limit: 500M
mem_reservation: 150M
mem_swappiness: 0

zeo:
image: imiobe/iadelib:dev
command: zeoserver
Expand All @@ -33,7 +32,6 @@ services:
SERVICE_NAME: "zeo"
healthcheck:
test: "/plone/zeo_healthcheck.sh"

instance:
image: imiobe/iadelib:dev
command: instance
Expand All @@ -45,13 +43,13 @@ services:
depends_on:
- zeo
- libreoffice
- worker-cron
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
- CLUSTER=iadelib_pm42
- HOSTNAME=instance1
- PLONE_PATH=demo
- ADMIN_PASSWORD=test
volumes:
- ./data/:/data
- tmp:/tmp
Expand All @@ -60,7 +58,32 @@ services:
test: "curl -f localhost:8081/$$PLONE_PATH/@@ok"
labels:
SERVICE_NAME: "instance1"

worker-cron:
image: imiobe/iadelib:dev
command: instance-cron
ports:
- "8087:8087"
networks:
- delib_internal
- delib_external
depends_on:
- zeo
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
- ADMIN_PASSWORD=test
- PUBLIC_URL=http://localhost/PM
- PLONE_PATH=demo
- CLUSTER=iadelib_pm42
- HOSTNAME=worker-cron
volumes:
- ./data/:/data
- tmp:/tmp
- vartmp:/var/tmp
healthcheck:
test: "curl -f localhost:8087/$$PLONE_PATH/@@ok"
labels:
SERVICE_NAME: "worker-cron"
worker-async:
image: imiobe/iadelib:dev
command: instance-async
Expand All @@ -69,6 +92,7 @@ services:
depends_on:
- zeo
- libreoffice
- worker-cron
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
Expand All @@ -83,7 +107,39 @@ services:
- vartmp:/var/tmp
labels:
SERVICE_NAME: "worker-async"

# worker-amqp:
# image: imiobe/iadelib:dev
# command: instance-amqp
# ports:
# - "20085:8286"
# networks:
# - delib_internal
# - delib_external
# depends_on:
# - zeo
# - worker-cron
# environment:
# - ZEO_CLIENT_CACHE_SIZE=1000MB
# - ZODB_CACHE_SIZE=100000
# - CLUSTER=iadelib_pm42
# - PLONE_PATH=demo
# - MQ_CLIENT_ID
# - MQ_WS_URL
# - MQ_WS_LOGIN
# - MQ_WS_PASSWORD
# - MQ_HOST
# - MQ_PORT
# - MQ_LOGIN
# - MQ_PASSWORD
# - HOSTNAME=worker-amqp
# healthcheck:
# test: "curl -f localhost:8286/$$PLONE_PATH/@@ok"
# volumes:
# - ./data/:/data
# - tmp:/tmp
# - vartmp:/var/tmp
# labels:
# SERVICE_NAME: "worker-cron"
maintenance:
image: imiobe/iadelib:dev
ports:
Expand All @@ -110,7 +166,6 @@ services:
- vartmp:/var/tmp
labels:
SERVICE_NAME: "maintenance"

volumes:
tmp:
vartmp:
Expand Down
33 changes: 31 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ services:
depends_on:
- zeo
- libreoffice
- worker-cron
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
- CLUSTER=iadelib_pm42
- HOSTNAME=instance1
- PLONE_PATH=demo
- ADMIN_PASSWORD=test
volumes:
- ./data:/data
- tmp:/tmp
Expand All @@ -62,6 +62,33 @@ services:
labels:
SERVICE_NAME: "instance1"

worker-cron:
image: imiobe/iadelib:latest
command: instance-cron
ports:
- "8087:8087"
networks:
- delib_internal
- delib_external
depends_on:
- zeo
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
- ADMIN_PASSWORD=test
- PUBLIC_URL=http://localhost/PM
- PLONE_PATH=demo
- CLUSTER=iadelib_pm42
- HOSTNAME=worker-cron
volumes:
- ./data:/data
- tmp:/tmp
- vartmp:/var/tmp
healthcheck:
test: "curl -f localhost:8087/$$PLONE_PATH/@@ok"
labels:
SERVICE_NAME: "worker-cron"

worker-async:
image: imiobe/iadelib:latest
command: instance-async
Expand Down Expand Up @@ -95,6 +122,7 @@ services:
- delib_external
depends_on:
- zeo
- worker-cron
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
Expand All @@ -116,7 +144,7 @@ services:
- tmp:/tmp
- vartmp:/var/tmp
labels:
SERVICE_NAME: "worker-amqp"
SERVICE_NAME: "worker-cron"

maintenance:
image: imiobe/iadelib:latest
Expand All @@ -128,6 +156,7 @@ services:
depends_on:
- zeo
- libreoffice
- worker-cron
environment:
- ZEO_CLIENT_CACHE_SIZE=1000MB
- ZODB_CACHE_SIZE=100000
Expand Down
30 changes: 30 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ function setup() {
fi
chmod 777 /data/*
}
function wait_for_cron() {
echo "Waiting for cron"
URL="worker-cron:8087/$PLONE_PATH"
CURL="curl --write-out %{http_code} -so /dev/null $URL/@@ok"
MAX_TRIES=50
INTERVAL=5
set +e
SECONDS=0
response="404"
tries=0
while [[ $response != "200" && $tries -lt $MAX_TRIES ]]
do
sleep $INTERVAL
echo "Waiting for cron"
response=$($CURL)
((tries+=1))
done
set -e
if [[ $tries == "$MAX_TRIES" ]]; then
echo "Failed to reach $URL after $SECONDS s"
exit 1
else
echo "$URL is up. Waited $SECONDS s"
fi
}
function start() {
echo "Starting $1"
cmd="bin/$1"
Expand All @@ -36,6 +61,11 @@ function start() {

setup "$1"

PRIORIY="instance-cron instance-debug maintenance script zeoserver"
if [[ "instance" == "$1" || ( ! $PRIORIY == *"$1"* && $# -gt 0 ) ]]; then
wait_for_cron "$1"
fi

case "$1" in
"")
exit 0
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
self.instance1_conf = '/plone/parts/instance/etc/zope.conf'
self.instance_amqp_conf = '/plone/parts/instance-amqp/etc/zope.conf'
self.instance_async_conf = '/plone/parts/instance-async/etc/zope.conf'
self.instance_cron_conf = '/plone/parts/instance-cron/etc/zope.conf'
self.instance_debug_conf = '/plone/parts/instance-debug/etc/zope.conf'
self.zeoserver_conf = '/plone/parts/zeoserver/etc/zeo.conf'

Expand Down Expand Up @@ -83,9 +84,10 @@ def _fix_amqp(self, path):
def fixtures(self):
""" ZEO Client
"""
self._fix_conf(self.instance1_conf, True)
self._fix_conf(self.instance1_conf, False)
self._fix_conf(self.instance_async_conf, False)
self._fix_conf(self.instance_amqp_conf, False)
self._fix_conf(self.instance_cron_conf, True)
# instance debug doesn't exist in dev env
if os.path.exists(self.instance_debug_conf):
self._fix_conf(self.instance_debug_conf, False)
Expand Down

0 comments on commit 2136b4d

Please sign in to comment.