运行 Travis Xenial 构建主机上的 Elasticsearch-7.0
Running Elasticsearch-7.0 on a Travis Xenial build host
Travis-CI 上的 Xenial (Ubuntu 16.04) 映像预装了 Elasticsearch-5.5。我应该在 .travis.yml
到 运行 我针对 Elasticsearch-7.0 的构建中添加什么?
将这些命令添加到您的 before_install
步骤:
- curl -s -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.1-amd64.deb
- sudo dpkg -i --force-confnew elasticsearch-7.0.1-amd64.deb
- 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
- sudo systemctl start elasticsearch
对 jvm.options
的更改是为了模拟 Elasticsearch-5.5 的现有配置,我认为 Travis peeps 已经真正考虑过了。
根据 Travis docs,您还应该将此行添加到您的 before_script
步骤:
- sleep 10
这是为了确保 Elasticsearch 已启动并且 运行,但我还没有检查它是否真的有必要。
@kthy 回答的一个小补充让我有点磕磕绊绊。您需要从您的服务中删除 - elasticsearch
:.travis.yml 中的定义,否则无论您在 before_install
中输入什么内容,默认服务都会覆盖它!
services:
- elasticsearch
删除 ^^ 然后你可以继续他概述的步骤,一切都会顺利进行。
如果您想等待弹性搜索开始(可能长于或短于 10 秒),请将 sleep 10
替换为:
host="localhost:9200"
response=""
attempt=0
until [ "$response" = "200" ]; do
if [ $attempt -ge 25 ]; then
echo "FAILED. Elasticsearch not responding after $attempt tries."
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
Travis-CI 上的 Xenial (Ubuntu 16.04) 映像预装了 Elasticsearch-5.5。我应该在 .travis.yml
到 运行 我针对 Elasticsearch-7.0 的构建中添加什么?
将这些命令添加到您的 before_install
步骤:
- curl -s -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.1-amd64.deb
- sudo dpkg -i --force-confnew elasticsearch-7.0.1-amd64.deb
- 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
- sudo systemctl start elasticsearch
对 jvm.options
的更改是为了模拟 Elasticsearch-5.5 的现有配置,我认为 Travis peeps 已经真正考虑过了。
根据 Travis docs,您还应该将此行添加到您的 before_script
步骤:
- sleep 10
这是为了确保 Elasticsearch 已启动并且 运行,但我还没有检查它是否真的有必要。
@kthy 回答的一个小补充让我有点磕磕绊绊。您需要从您的服务中删除 - elasticsearch
:.travis.yml 中的定义,否则无论您在 before_install
中输入什么内容,默认服务都会覆盖它!
services:
- elasticsearch
删除 ^^ 然后你可以继续他概述的步骤,一切都会顺利进行。
如果您想等待弹性搜索开始(可能长于或短于 10 秒),请将 sleep 10
替换为:
host="localhost:9200"
response=""
attempt=0
until [ "$response" = "200" ]; do
if [ $attempt -ge 25 ]; then
echo "FAILED. Elasticsearch not responding after $attempt tries."
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