Setup Elasticsearch indexes during Deploy and Local App Setup (#5939)
* setup Elasticsearch indexes during deploy and local app setup * cleanup previous duplicate sentence * remove more duplicate docs
This commit is contained in:
parent
7909d9825d
commit
a13533c920
4 changed files with 20 additions and 10 deletions
|
|
@ -28,6 +28,9 @@ chdir APP_ROOT do
|
|||
puts "\n== Preparing database =="
|
||||
system! 'bin/rails db:setup'
|
||||
|
||||
puts "\n== Preparing Elasticsearch =="
|
||||
system! 'bin/rails search:setup'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ chdir APP_ROOT do
|
|||
puts "\n== Updating database =="
|
||||
system! 'bin/rails db:migrate'
|
||||
|
||||
puts "\n== Update Elasticsearch =="
|
||||
system! 'bin/rails search:setup'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ Some of the steps will be parallelized in the future:
|
|||
1. `bundle-audit` checks for any known vulnerability.
|
||||
1. Travis builds Storybook to ensure its integrity.
|
||||
1. Travis deploys code to Heroku.
|
||||
- Heroku runs the database migrations before deployment.
|
||||
- Heroku runs the database migrations and Elasticsearch updates before
|
||||
deployment.
|
||||
1. Travis notifies the team that the process completed.
|
||||
|
||||
## Deploying to Heroku
|
||||
|
|
@ -44,13 +45,14 @@ This will cause the release script to exit with a code of 1 which will halt the
|
|||
deploy. This ensures that we don't accidentally push out code while we are
|
||||
waiting for a fix or running other tasks. Next, we run any outstanding
|
||||
migrations. This ensures that a migration finishes successfully before the code
|
||||
that uses it goes live. After running migrations, we use the Rails runner to
|
||||
output a simple string. Executing a Rails runner command ensures that we can
|
||||
boot up the entire app successfully before it is deployed. We deploy
|
||||
asynchronously, so the website is running the new code a few minutes after
|
||||
deploy. A new instance of Heroku Rails console will immediately run a new code.
|
||||
We deploy asynchronously, so the website is running the new code a few minutes
|
||||
after deploy. A new instance of Heroku Rails console will immediately run a new
|
||||
code.
|
||||
that uses it goes live. After running migrations, we update Elasticsearch.
|
||||
Elasticsearch contains indexes which have mappings. Mappings are similar to
|
||||
database schema. The same way we run a migration to update our database we have
|
||||
to run a setup task to update any Elasticsearch mappings. Following updating all
|
||||
of our datastores we use the Rails runner to output a simple string. Executing a
|
||||
Rails runner command ensures that we can boot up the entire app successfully
|
||||
before it is deployed. We deploy asynchronously, so the website is running the
|
||||
new code a few minutes after deploy. A new instance of Heroku Rails console will
|
||||
immediately run a new code.
|
||||
|
||||

|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ set -x
|
|||
# abort release if deploy status equals "blocked"
|
||||
[[ $DEPLOY_STATUS = "blocked" ]] && echo "Deploy blocked" && exit 1
|
||||
|
||||
# runs migration and boots the app to check there are no errors
|
||||
# runs migration for Postgres, setups/updates Elasticsearch
|
||||
# and boots the app to check there are no errors
|
||||
STATEMENT_TIMEOUT=180000 bundle exec rails db:migrate && \
|
||||
bundle exec rake search:setup && \
|
||||
bundle exec rails runner "puts 'app load success'"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue