Merge pull request #2389 from Growstuff/dev

Production release
This commit is contained in:
Brenda Wallace
2020-01-20 14:30:36 +13:00
committed by GitHub
9 changed files with 48 additions and 35 deletions

View File

@@ -19,9 +19,7 @@ addons:
secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk="
env:
matrix:
# - ELASTIC_SEARCH_VERSION="7.5.1-amd64" COVERAGE=true RAILS_ENV=test # Future target (production needs upgrading)
# - ELASTIC_SEARCH_VERSION="6.7.1" COVERAGE=true RAILS_ENV=test # last 6.x release
- ELASTIC_SEARCH_VERSION="6.2.3" COVERAGE=true RAILS_ENV=test # matches productions
- ELASTIC_SEARCH_VERSION="7.5.1-amd64" COVERAGE=true RAILS_ENV=test # Future target (production needs upgrading)
- STATIC_CHECKS=true
global:
- secure: "Z5TpM2jEX4UCvNePnk/LwltQX48U2u9BRc+Iypr1x9QW2o228QJhPIOH39a8RMUrepGnkQIq9q3ZRUn98RfrJz1yThtlNFL3NmzdQ57gKgjGwfpa0e4Dwj/ZJqV2D84tDGjvdVYLP7zzaYZxQcwk/cgNpzKf/jq97HLNP7CYuf4="
@@ -32,9 +30,10 @@ before_install:
- sudo apt clean
- sudo apt update
- sudo apt install dpkg
- ./script/install_elasticsearch.sh
- sudo apt install google-chrome-stable
- ./script/install_linters.sh
- ./script/install_elasticsearch.sh
- ./script/check_elasticsearch.sh
script:
- >
if [ "${STATIC_CHECKS}" = "true" ]; then

View File

@@ -183,8 +183,8 @@ GEM
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
faker (2.10.0)
i18n (>= 1.6, < 1.8)
faker (2.10.1)
i18n (>= 1.6, < 2)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.13.1)
@@ -241,7 +241,7 @@ GEM
httparty (0.17.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.7.1)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
i18n-tasks (0.9.30)
activesupport (>= 4.0.2)

View File

@@ -10,7 +10,7 @@ module SearchCrops
searchable: %i(name descriptions alternate_names scientific_names),
case_sensitive: false,
merge_mappings: true,
settings: { number_of_shards: 1 },
settings: { number_of_shards: 1, number_of_replicas: 0 },
mappings: {
properties: {
created_at: { type: :integer },

View File

@@ -5,7 +5,7 @@ module SearchHarvests
included do
searchkick merge_mappings: true,
settings: { number_of_shards: 1 },
settings: { number_of_shards: 1, number_of_replicas: 0 },
mappings: {
properties: {
harvests_count: { type: :integer },

View File

@@ -5,7 +5,7 @@ module SearchPhotos
included do
searchkick merge_mappings: true,
settings: { number_of_shards: 1 },
settings: { number_of_shards: 1, number_of_replicas: 0 },
mappings: {
properties: {
title: { type: :text },

View File

@@ -5,7 +5,7 @@ module SearchPlantings
included do
searchkick merge_mappings: true,
settings: { number_of_shards: 1 },
settings: { number_of_shards: 1, number_of_replicas: 0 },
mappings: {
properties: {
active: { type: :boolean },

View File

@@ -5,7 +5,7 @@ module SearchSeeds
included do
searchkick merge_mappings: true,
settings: { number_of_shards: 1 },
settings: { number_of_shards: 1, number_of_replicas: 0 },
mappings: {
properties: {
id: { type: :integer },

28
script/check_elasticsearch.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
if [[ -z "$ELASTIC_SEARCH_VERSION" ]]; then
echo "ELASTIC_SEARCH_VERSION variable not set"
else
host="localhost:9200"
response=""
attempt=0
maxattempts=25
# this would wait forever
# until curl --silent -XGET --fail ${host} do printf '.'; sleep 1; done
until [ "$response" = "200" ]; do
if [ $attempt -ge ${maxattempts} ]; then
echo "FAILED. Elasticsearch not responding after $attempt tries."
sudo tail /var/log/elasticsearch/*.log
exit 1
fi
echo "Contacting Elasticsearch on ${host}. Try number ${attempt}"
response=$(curl --write-out %{http_code} --silent --output /dev/null $host)
sleep 1
attempt=$((attempt+1))
done
echo "SUCCESS. Elasticsearch is responding."
fi

View File

@@ -12,33 +12,19 @@ else
shasum -a 512 -c "elasticsearch-${ELASTIC_SEARCH_VERSION}.deb.sha512"
echo "Installing Elasticsearch ${ELASTIC_SEARCH_VERSION}"
sudo dpkg -i --force-confnew "elasticsearch-${ELASTIC_SEARCH_VERSION}.deb"
if [[ $ELASTIC_SEARCH_VERSION == 7\.* ]]; then
# https://stackoverflow.com/questions/55951531/running-elasticsearch-7-0-on-a-travis-xenial-build-host
sudo sed -i.old 's/-Xms1g/-Xms128m/' /etc/elasticsearch/jvm.options
sudo sed -i.old 's/-Xmx1g/-Xmx128m/' /etc/elasticsearch/jvm.options
echo -e '-XX:+DisableExplicitGC\n-Djdk.io.permissionsUseCanonicalPath=true\n-Dlog4j.skipJansi=true\n-server\n' | sudo tee -a /etc/elasticsearch/jvm.options
sudo chown -R elasticsearch:elasticsearch /etc/default/elasticsearch
fi
echo "Starting Elasticsearch ${ELASTIC_SEARCH_VERSION}"
# sudo service elasticsearch start
sudo systemctl start elasticsearch
host="localhost:9200"
response=""
attempt=0
maxattempts=25
# this would wait forever
# until curl --silent -XGET --fail ${host} do printf '.'; sleep 1; done
until [ "$response" = "200" ]; do
if [ $attempt -ge ${maxattempts} ]; then
echo "FAILED. Elasticsearch not responding after $attempt tries."
sudo tail /var/log/elasticsearch/*.log
exit 1
fi
echo "Contacting Elasticsearch on ${host}. Try number ${attempt}"
response=$(curl --write-out %{http_code} --silent --output /dev/null $host)
sleep 1
attempt=$((attempt+1))
done
fi
echo "SUCCESS. Elasticsearch is responding."