Skip to content

Commit ac1215e

Browse files
agjohnsonhumitos
andauthored
Use nodemon for reloading on all server processes (#160)
* Use nodemon for reloading on all server processes This examples nodemon from the celery entrypoint script to the web and proxito service entrypoint scripts. The Django runserver --reload option doesn't see to be configurable, and seems to watch a lot of files that are not needed for reloading. I can't tell what exactly is being watched by runserver, but I am getting frequent `too many open files` errors from processes in Docker. Running with --no-reload mostly solves this issue, but requires manually restarting services. Someone else should spend some time with this, I'm not confident that this will: 1. Fix the issue for others 2. Not cause irreparable damage to your local installation * Actually noreload on django runserver commands * Use gunicorn * Update nodemon configuration * More nodemon settings --------- Co-authored-by: Manuel Kaufmann <[email protected]>
1 parent c4f7e4b commit ac1215e

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

dockerfiles/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
- ${PWD}/common/dockerfiles/entrypoints/proxito.sh:/usr/src/app/docker/proxito.sh
3636
- ${PWD}/${RTDDEV_PATH_EXT:-../readthedocs-ext}:/usr/src/app/checkouts/readthedocs-ext
3737
- ${PWD}/${RTDDEV_PATH_EXT_THEME:-../ext-theme}:/usr/src/app/checkouts/ext-theme
38+
- ${PWD}/common/dockerfiles/nodemon.json:/usr/src/app/checkouts/nodemon.json
3839
links:
3940
- storage
4041
- database
@@ -59,6 +60,7 @@ services:
5960
- ${PWD}/common/dockerfiles/entrypoints/web.sh:/usr/src/app/docker/web.sh
6061
- ${PWD}/common/dockerfiles/entrypoints/createbuckets.sh:/usr/src/app/docker/createbuckets.sh
6162
- ${PWD}/common/dockerfiles/entrypoints/wait-for-it.sh:/usr/src/app/docker/wait-for-it.sh
63+
- ${PWD}/common/dockerfiles/nodemon.json:/usr/src/app/checkouts/nodemon.json
6264
- ${PWD}/${RTDDEV_PATH_EXT:-../readthedocs-ext}:/usr/src/app/checkouts/readthedocs-ext
6365
- ${PWD}/${RTDDEV_PATH_EXT_THEME:-../ext-theme}:/usr/src/app/checkouts/ext-theme
6466
links:

dockerfiles/entrypoints/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ mkdir -p $CELERY_STATE_DIR
1212
CMD="python3 -m celery -A ${CELERY_APP_NAME}.worker worker -Ofair -c 1 -Q builder,celery,default,build01,build:default,build:large -l ${CELERY_LOG_LEVEL} --statedb=${CELERY_STATE_DIR}worker.state"
1313

1414
if [ -n "${DOCKER_NO_RELOAD}" ]; then
15-
echo "Running Docker with no reload"
15+
echo "Running process with no reload"
1616
$CMD
1717
else
18-
echo "Running Docker with reload"
18+
echo "Running process with reload"
1919
nodemon --config ../nodemon.json --exec $CMD
2020
fi

dockerfiles/entrypoints/celery.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ fi
1111
CMD="python3 -m celery -A ${CELERY_APP_NAME}.worker worker -Ofair -c 2 -Q web,web01,reindex,autoscaling -l ${CELERY_LOG_LEVEL}"
1212

1313
if [ -n "${DOCKER_NO_RELOAD}" ]; then
14-
echo "Running Docker with no reload"
14+
echo "Running process with no reload"
1515
$CMD
1616
else
17-
echo "Running Docker with reload"
17+
echo "Running process with reload"
1818
nodemon --config ../nodemon.json --exec $CMD
1919
fi

dockerfiles/entrypoints/proxito.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
../../docker/common.sh
44

5-
if [ -n "${DOCKER_NO_RELOAD}" ];
6-
then
7-
RELOAD='--noreload'
8-
echo "Running Docker with no reload"
5+
CMD="gunicorn readthedocs.wsgi:application -w 3 -b 0.0.0.0:8000 --max-requests=10000"
6+
7+
if [ -n "${DOCKER_NO_RELOAD}" ]; then
8+
echo "Running process with no reload"
9+
$CMD
910
else
10-
RELOAD=''
11-
echo "Running Docker with reload"
11+
echo "Running process with reload"
12+
nodemon --config ../nodemon.json --exec "${CMD}"
1213
fi
13-
14-
python3 manage.py runserver 0.0.0.0:8000 $RELOAD

dockerfiles/entrypoints/web.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ then
1313
python3 manage.py loaddata test_data
1414
fi
1515

16-
if [ -n "${DOCKER_NO_RELOAD}" ];
17-
then
18-
RELOAD='--noreload'
19-
echo "Running Docker with no reload"
16+
CMD="gunicorn readthedocs.wsgi:application -w 3 -b 0.0.0.0:8000 --max-requests=10000"
17+
18+
if [ -n "${DOCKER_NO_RELOAD}" ]; then
19+
echo "Running process with no reload"
20+
$CMD
2021
else
21-
RELOAD=''
22-
echo "Running Docker with reload"
22+
echo "Running process with reload"
23+
nodemon --config ../nodemon.json --exec "${CMD}"
2324
fi
24-
25-
python3 manage.py runserver 0.0.0.0:8000 $RELOAD

dockerfiles/nodemon.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"verbose": true,
3-
"delay": 2500,
2+
"verbose": false,
3+
"delay": 2000,
44
"ext": "py",
55
"watch": ["readthedocs", "readthedocsinc"],
6-
"ignore": [".tox/*", ".direnv/*", "user_builds/*", "*/management/commands*", "*migrations/*", "*test*", "*.pyc", "*.pyo"],
6+
"ignore": [".tox/*", ".direnv/*", "user_builds/*", "*/management/commands*", "*migrations/*", "*test*", "*.pyc", "*.pyo", "logs/*"],
77
"signal": "SIGTERM"
88
}

0 commit comments

Comments
 (0)