Skip to content

Commit

Permalink
build(snap): kong migrations up before Kong startup (#4223)
Browse files Browse the repository at this point in the history
Signed-off-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
  • Loading branch information
farshidtz committed Oct 26, 2022
1 parent 4dda876 commit c8dc4aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions snap/local/runtime-helpers/bin/kong-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

KONG=/usr/local/bin/kong

# run kong migrations up to bootstrap the cassandra database
# note that sometimes cassandra can be in a "starting up" state, etc.
# bootstrap the database
# note that sometimes the database can be in a "starting up" state, etc.
# and in this case we should just loop and keep trying
# we don't implement a timeout here because systemd will kill us if we
# don't succeed in 15 minutes (or whatever the configured stop-timeout is)
until "$KONG" migrations bootstrap --conf "$KONG_CONF"; do
sleep 5
done

# perform migration for upgrades
"$KONG" migrations up --conf "$KONG_CONF"

# set up Kong's admin API plugins via kong.yml:
"$KONG" config db_import "$KONGADMIN_CONFIGFILEPATH" || true

Expand Down
8 changes: 4 additions & 4 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,23 +696,23 @@ parts:
- perl
- zlib1g-dev
override-build: |
VERSION=2.8.0
VERSION=2.8.2
# use dpkg architecture to figure out our target arch
case "$(dpkg --print-architecture)" in
amd64)
FILE_NAME=kong_${VERSION}_amd64.deb
FILE_HASH=5715ec10547a2de9e7534d0af402fc8dbdad7145d4b43bbccc7bb960152b0314
FILE_HASH=d600227d07cb862b2dd2de3925eca5841b2292ef838af21ddf5f412c9ab0f3ee
;;
arm64)
FILE_NAME=kong_${VERSION}_arm64.deb
FILE_HASH=d980f5c106a36142dd86c04bee4adc0deec3470970f8b0f6d3024c17e13d83d6
FILE_HASH=c23b22bf34df1f3a8428c998875e868025557d5f9599fd9bed10b12c9fb8ed57
;;
esac
# download the archive and verify the checksum
curl --silent --show-error --location --output $FILE_NAME \
https://download.konghq.com/gateway-2.x-ubuntu-xenial/pool/all/k/kong/$FILE_NAME
https://download.konghq.com/gateway-2.x-ubuntu-focal/pool/all/k/kong/$FILE_NAME
echo "$FILE_HASH $FILE_NAME" > sha256
sha256sum -c sha256 | grep OK
Expand Down

0 comments on commit c8dc4aa

Please sign in to comment.