Skip to content

Commit 0762714

Browse files
committed
Merge pull request #1383 from deis/fix-check-cmd
fix(confd): simplify check_cmd and fix grep usage
2 parents 715bbca + dc55257 commit 0762714

10 files changed

Lines changed: 16 additions & 47 deletions

File tree

controller/bin/boot

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,21 @@ until confd -onetime -node $ETCD -config-file /app/confd.toml 2>/dev/null; do
4646
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
4747
done
4848

49-
# wait for confd to populate all values
50-
while grep -q '<no value>' /templates/confd_settings.py; do
51-
echo "controller: waiting for confd to write all values..."
52-
confd -onetime -node $ETCD -config-file /app/confd.toml 2>/dev/null
53-
sleep $(($ETCD_TTL/2)) # sleep for half the TTL
54-
done
55-
5649
cd /app
5750

5851
# run an idempotent database migration
5952
sudo -E -u deis ./manage.py syncdb --migrate --noinput
6053

61-
# spawn celery worker in the background
54+
# spawn celery workers in the background
6255
sudo -E -u deis celery worker --app=deis --loglevel=INFO --workdir=/app --pidfile=/tmp/celery.pid &
63-
CELERY_PID=$!
6456

65-
# spawn a gunicorn server in the foreground
57+
# spawn a gunicorn server in the background
6658
sudo -E -u deis ./manage.py run_gunicorn -b 0.0.0.0 -w 8 -t 600 -n deis --log-level debug --pid=/tmp/gunicorn.pid --preload &
67-
GUNICORN_PID=$!
6859

6960
# smart shutdown on SIGINT and SIGTERM
7061
function on_exit() {
62+
CELERY_PID=$(cat /tmp/celery.pid)
63+
GUNICORN_PID=$(cat /tmp/gunicorn.pid)
7164
kill -TERM $CELERY_PID $GUNICORN_PID
7265
wait $CELERY_PID $GUNICORN_PID 2>/dev/null
7366
exit 0

controller/bin/check

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@
33
# Check that the configuration for deis-controller is valid.
44
#
55

6-
if [[ -f /templates/confd_settings.py ]] ; then
7-
set -e
8-
9-
# check that "<no value>" isn't in the templated file
10-
grep -q -v "<no value>" /templates/confd_settings.py
11-
12-
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
13-
PARENT_DIR=$(dirname $THIS_DIR)
14-
15-
# check the Django configuration file compatibility
16-
$PARENT_DIR/manage.py check > /dev/null
17-
18-
# validate the Django models
19-
$PARENT_DIR/manage.py validate > /dev/null
6+
if grep -q "<no value>" $1 ; then
7+
exit 1
208
fi

controller/bin/reload

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ kill -HUP $(cat /tmp/celery.pid)
66
# gracefully reload gunicorn
77
kill -HUP $(cat /tmp/gunicorn.pid)
88

9-
exit 0
9+
exit 0

controller/conf.d/confd_settings.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ keys = [
1111
"/deis/registry",
1212
"/deis/domains",
1313
]
14-
check_cmd = "/app/bin/check"
14+
check_cmd = "/app/bin/check {{ .src }}"
1515
reload_cmd = "/app/bin/reload"

database/bin/check

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33
# Check that the configuration for deis-database is valid.
44
#
55

6-
set -e
7-
8-
# check that "<no value>" isn't in the templated files
9-
if [[ -f /etc/postgresql/9.3/main/postgresql.conf ]] ; then
10-
grep -q -v "<no value>" /etc/postgresql/9.3/main/postgresql.conf
11-
fi
12-
if [[ -f /etc/postgresql/9.3/main/pg_hba.conf ]] ; then
13-
grep -q -v "<no value>" /etc/postgresql/9.3/main/pg_hba.conf
14-
fi
15-
if [[ -f /usr/local/bin/reload ]] ; then
16-
grep -q -v "<no value>" /usr/local/bin/reload
6+
if grep -q "<no value>" $1 ; then
7+
exit 1
178
fi

database/conf.d/pg_hba.conf.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ mode = "0640"
77
keys = [
88
"/deis/database",
99
]
10-
check_cmd = "/app/bin/check"
10+
check_cmd = "/app/bin/check {{ .src }}"
1111
reload_cmd = "/usr/local/bin/reload"

database/conf.d/postgresql.conf.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ mode = "0644"
77
keys = [
88
"/deis/database",
99
]
10-
check_cmd = "/app/bin/check"
10+
check_cmd = "/app/bin/check {{ .src }}"
1111
reload_cmd = "/usr/local/bin/reload"

database/conf.d/reload.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ mode = "0755"
77
keys = [
88
"/deis/database",
99
]
10-
check_cmd = "/app/bin/check"
10+
check_cmd = "/app/bin/check {{ .src }}"
1111
reload_cmd = "/usr/local/bin/reload"

registry/bin/check

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# Check that the configuration for deis-registry is valid.
44
#
55

6-
if [[ -f /docker-registry/config/config.yml ]] ; then
7-
set -e
8-
9-
# check that "<no value>" isn't in the templated file
10-
grep -q -v "<no value>" /docker-registry/config/config.yml
6+
if grep -q "<no value>" $1 ; then
7+
exit 1
118
fi

registry/conf.d/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ mode = "0644"
77
keys = [
88
"/deis/registry",
99
]
10-
check_cmd = "/app/bin/check"
10+
check_cmd = "/app/bin/check {{ .src }}"
1111
reload_cmd = "/app/bin/reload"

0 commit comments

Comments
 (0)