I'm trying to run the below command inside docker container using Dockerfile
jmeter -n -t nature.jmx -l nature.jtl
I tried running this command using RUN and CMD
CMD ["jmeter", "-n"," -t nature.jmx -l nature1.jtl"]
RUN "jmeter -n -t nature.jmx -l nature.jtl"
RUN jmeter -n -t nature.jmx -l nature.jtl
but none of the above command works. i keep getting the below error:
C:\Program Files\Docker\docker.exe: Error response from daemon:
container 02323b3d347904331938b0d27c639975899284b06a0e2f377350
833b55f1ef46 encountered an error during CreateProcess: failure in a
Windows system call: The system cannot find the file spec ified. (0x2)
extra info: {"ApplicationName":"","CommandLine":"jmeter -n -t
nature.jmx -l nature1.jtl","User":"","WorkingDirec
tory":"C:\jmeter\apache-jmeter-3.1\bin","Environment":{"JAVA_HOME":"C:\ojdkbuild","JAVA_OJDKBUILD_SHA256":"7e7384636054001
499ba96d55c90fc39cbb0441281254a1e9ac8510b527a7a46","JAVA_OJDKBUILD_VERSION":"1.8.0.131-1","JAVA_OJDKBUILD_ZIP":"java-1.8.0-ope njdk-1.8.0.131-1.b11.ojdkbuild.windows.x86_64.zip","JAVA_VERSION":"8u131","JMETER_HOME":"C:/jmeter/apache-jmeter-3.1","SET":"P ATH=C:ProgramDataOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C
:ojdkbuildbin;C:/jmeter/apache-jmeter-3.1bin;"},"EmulateConsole":false,"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateS
tdErrPipe":true,"ConsoleSize":[0,0]}. PS C:\Users\Administrator>
Any advise on this would be helpful. Thanks in advance. Please find my docketing:
Experimental: false
PS C:\Users\Administrator>
Trying build the image using the below Dockerfile
FROM microsoft/windowsservercore
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV JAVA_HOME C:\\ojdkbuild
RUN $newPath = ('{0}\bin;{1}' -f $env:JAVA_HOME, $env:PATH); \
Write-Host ('Updating PATH: {0}' -f $newPath); \
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
setx /M PATH $newPath;
# https://github.com/ojdkbuild/ojdkbuild/releases
ENV JAVA_VERSION 8u131
ENV JAVA_OJDKBUILD_VERSION 1.8.0.131-1
ENV JAVA_OJDKBUILD_ZIP java-1.8.0-openjdk-1.8.0.131-1.b11.ojdkbuild.windows.x86_64.zip
ENV JAVA_OJDKBUILD_SHA256 7e7384636054001499ba96d55c90fc39cbb0441281254a1e9ac8510b527a7a46
RUN $url = ('https://github.com/ojdkbuild/ojdkbuild/releases/download/{0}/{1}' -f $env:JAVA_OJDKBUILD_VERSION, $env:JAVA_OJDKBUILD_ZIP); \
Write-Host ('Downloading {0} ...' -f $url); \
Invoke-WebRequest -Uri $url -OutFile 'ojdkbuild.zip'; \
Write-Host ('Verifying sha256 ({0}) ...' -f $env:JAVA_OJDKBUILD_SHA256); \
if ((Get-FileHash ojdkbuild.zip -Algorithm sha256).Hash -ne $env:JAVA_OJDKBUILD_SHA256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
Write-Host 'Expanding ...'; \
Expand-Archive ojdkbuild.zip -DestinationPath C:\; \
\
Write-Host 'Renaming ...'; \
Move-Item \
-Path ('C:\{0}' -f ($env:JAVA_OJDKBUILD_ZIP -Replace '.zip$', '')) \
-Destination $env:JAVA_HOME \
; \
\
Write-Host 'Verifying install ...'; \
Write-Host ' java -version'; java -version; \
Write-Host ' javac -version'; javac -version; \
\
Write-Host 'Removing ...'; \
Remove-Item ojdkbuild.zip -Force; \
\
Write-Host 'Complete.';
#CMD ["java","-version"]
# Install jmeter
RUN mkdir C:\jmeter
RUN cd /jmeter
RUN powershell.exe Invoke-WebRequest -usebasicparsing http://ftp.ps.pl/pub/apache/jmeter/binaries/apache-jmeter-3.1.zip -OutFile c:/apache-jmeter-3.1.zip
RUN powershell.exe Expand-Archive -Path C:\apache-jmeter-3.1.zip -DestinationPath C:/jmeter
#RUN mkdir C:/jmeter/apache-jmeter-2.13/apache-jmeter-3.1/jmeter-plugins
#RUN cd C:/jmeter/apache-jmeter-2.13/apache-jmeter-3.1/jmeter-plugins
#RUN Invoke-WebRequest -usebasicparsing https://jmeter-#plugins.org/downloads/file/JMeterPlugins-ExtrasLibs-1.4.0.zip
#RUN Expand-Archive -Path C:/jmeter/apache-jmeter-2.13/apache-jmeter-#3.1/jmeter-plugins -DestinationPath C:/jmeter/apache-jmeter-2.13/apache-#jmeter-3.1/jmeter-plugins
# Set Jmeter Home
ENV JMETER_HOME C:/jmeter/apache-jmeter-3.1
# Add Jmeter to the Path
ENV PATH $JMETER_HOME/bin:$PATH
COPY nature.jmx C:\\jmeter\\apache-jmeter-3.1\\bin\\nature.jmx
WORKDIR C:\\jmeter\\apache-jmeter-3.1\\bin
RUN jmeter -n -t nature.jmx -l nature.jtl
Related
I have a bash script which opens Unity with arguments and builds a library:
#!/bin/bash
UNITY=$1/$2/Unity.app/Contents/MacOS/Unity
[ "$(uname -s)" == "Darwin" ] && $UNITY -buildtarget $3 -nographics -batchmode -upmNoDefaultPackages -serial $4 -username $5 -password $6
I run it like this:
./openUnity.sh $UNITY_EDITORS_PATH $UNITY_VERSION $PLATFORM $UNITY_LICENSE $UNITY_USERNAME $UNITY_PASSWORD
How can I add additional arguments to all content above?
What I would like is:
./openUnity.sh $LIST_OF_ARGS_ABOVE $NEW_ARGUMENTS
-testPlatform %testPlatform% \
-deviceType %deviceType% \
-closeAfterExecution \
-autoTestRun \
-killProcessesAfterExecution
I cannot really add indefinite number of arguments and finish with $20
Arguments need to be added like: ./script.sh $1 $2 due to external software - using Teamcity
Is there any good approach to do it?
If you truly need args passed to the script, then the only solution is to use location-specific arguments. I suspect that you can use the environment though, since that is a primary mechanic in CI, and it uses the existing environment values that are being passed to the script. The only requirement is that those env vars be exported, which is common practice in CI.
Doing things from the environment when possible is great in CI, and it will make this easier for you because it avoids extending the number of location-specific parameters up too high, and lets the script used named variables instead of variables with numeric names.
For your existing script can be refactored like so (I've prepended an echo so we can see what would be run):
$ cat openUnity.sh
#!/bin/bash
set -u # abort on unassigned variable
UNITY="${UNITY_EDITORS_PATH}/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
[[ "$(uname -s)" == "Darwin" ]] && \
echo "$UNITY" \
-buildtarget "$PLATFORM" \
-nographics \
-batchmode \
-upmNoDefaultPackages \
-serial "$UNITY_LICENSE" \
-username "$UNITY_USERNAME" \
-password "$UNITY_PASSWORD"
$ export UNITY_EDITORS_PATH
$ export UNITY_EDITORS_PATH=/Application/Unit.app
$ export UNITY_VERSION=20.0.1
$ export PLATFORM=darwin
$ export UNITY_LICENSE=abc123
$ export UNITY_USERNAME=dade_murphy
$ export UNITY_PASSWORD=hunter2
$ ./openUnity.sh
/Application/Unit.app/20.0.1/Unity.app/Contents/MacOS/Unity -buildtarget darwin -nographics -batchmode -upmNoDefaultPackages -serial abc123 -username dade_murphy -password hunter2
Now, if your additional parameters will always exist, then adding them is simple:
#!/bin/bash
set -u # abort on unassigned variable
UNITY="${UNITY_EDITORS_PATH}/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
[[ "$(uname -s)" == "Darwin" ]] && \
echo "$UNITY" \
-buildtarget "$PLATFORM" \
-nographics \
-batchmode \
-upmNoDefaultPackages \
-serial "$UNITY_LICENSE" \
-username "$UNITY_USERNAME" \
-password "$UNITY_PASSWORD" \
-testPlatform "$testPlatform" \
-deviceType "$deviceType" \
-closeAfterExecution \
-autoTestRun \
-killProcessesAfterExecution
However, if the new args are optional, we would have to conditionally build a set of args to append:
#!/bin/bash
set -u # abort on unassigned variable
# build an array of required args
args=(
-buildtarget "$PLATFORM"
-nographics
-batchmode
-upmNoDefaultPackages
-serial "$UNITY_LICENSE"
-username "$UNITY_USERNAME"
-password "$UNITY_PASSWORD"
-closeAfterExecution
-autoTestRun
-killProcessesAfterExecution
)
# append any optional args if they are found in the environment
[[ -n "${testPlatform}" ]] && args+=(-testPlatform "$testPlatform")
[[ -n "${deviceType}" ]] && args+=(-deviceType "$deviceType")
UNITY="${UNITY_EDITORS_PATH}/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
# Call UNITY and expand the 'args' array into arguments
[[ "$(uname -s)" == "Darwin" ]] && echo "$UNITY" "${args[#]}"
/Application/Unit.app/20.0.1/Unity.app/Contents/MacOS/Unity -buildtarget darwin -nographics -batchmode -upmNoDefaultPackages -serial abc123 -username dade_murphy -password hunter2 -closeAfterExecution -autoTestRun -killProcessesAfterExecution
$ export deviceType=microwave
$ export testPlatform=irix
$ ./openUnity.sh
/Application/Unit.app/20.0.1/Unity.app/Contents/MacOS/Unity -buildtarget darwin -nographics -batchmode -upmNoDefaultPackages -serial abc123 -username dade_murphy -password hunter2 -closeAfterExecution -autoTestRun -killProcessesAfterExecution -testPlatform irix -deviceType microwave
I have unsuccessfully tried to use bash variables in Jenkins pipeline.
My first attempt
sh """#!/bin/bash
for file in *.map; do
filename=`basename $file .map`
echo "##### uploading ${$filename}"
curl -X POST ${SERVER_URL}/assets/v1/sourcemaps \
-F service_name="${SERVICE_NAME}" \
-F service_version="${revision}" \
-F bundle_filepath="${main_url}${filename}" \
-F sourcemap="#${filename}.map" &
done
wait
"""
Resulted in exception: MissingPropertyException: No such property: file
The second attempt, after seeing this answer https://stackoverflow.com/a/35047530/9590251
sh """#!/bin/bash
for file in *.map; do
filename=`basename \$file .map`
echo "##### uploading \$filename"
curl -X POST ${SERVER_URL}/assets/v1/sourcemaps \
-F service_name="${SERVICE_NAME}" \
-F service_version="${revision}" \
-F bundle_filepath="${main_url}\$filename" \
-F sourcemap="#\$filename.map" &
done
wait
"""
Simply omitted bash variables. So $filename was empty.
How do I need to property encode bash variables in this scenario?
Try this:
sh """#!/bin/bash
set -x
for file in *.map; do
filename="\$(basename "\$file" .map)"
echo "Uploading \$filename"
curl -X POST "${SERVER_URL}/assets/v1/sourcemaps" \
-F service_name="${SERVICE_NAME}" \
-F service_version="${revision}" \
-F bundle_filepath="${main_url}\$filename" \
-F sourcemap="#\${filename}.map" &
done
wait
"""
I'm trying to automate a post-build process to get closer to a one-click release. However, I'm having problems with a script that.
Expected: The script to work exactly like the command line.
Results: Everything works, including grabbing the versionCodes except I am getting a curl: (26) Failed to open/read local data from file/application
The script I wanted to imitate with a more automated approach.
react-native bundle \
--platform android \
--dev false \
--entry-file index.js \
--bundle-output android-release.bundle \
--sourcemap-output android-release.bundle.map &&
curl https://upload.bugsnag.com/react-native-source-map \
-F apiKey=API-KEY \
-F appVersion=10.6.7 \
-F appVersionCode=4515 \
-F dev=false \
-F platform=android \
-F sourceMap=#android-release.bundle.map \
-F bundle=#android-release.bundle
react-native bundle \
--platform ios \
--dev false \
--entry-file index.js \
--bundle-output ios-release.bundle \
--sourcemap-output ios-release.bundle.map &&
curl https://upload.bugsnag.com/react-native-source-map \
-F apiKey=API-KEY \
-F appVersion=10.6.7 \
-F appBundleVersion=4515 \
-F dev=false \
-F platform=ios \
-F sourceMap=#ios-release.bundle.map \
-F bundle=#ios-release.bundle
So I wrote a script to fix this, which is
#!/bin/sh
# Ensure this is run on the commit used to generate the published app!
# Comment this line out to enable bundling and publishing
# debug=echo
bundle () {
platform=$1
$debug yarn react-native bundle \
--platform "$platform" \
--dev false \
--entry-file index.js \
--bundle-output "$platform-release.bundle" \
--sourcemap-output "$platform-release.bundle.map"
}
upload () {
platform=$1
version=$2
version_code=$3
# See https://docs.bugsnag.com/api/rn-source-map-upload/#uploading-source-maps
curl --http1.1 https://upload.bugsnag.com/react-native-source-map \
-F apiKey="$BUGSNAG_API_KEY" \
-F appVersion="$version" \
-F appVersionCode="$version_code" \
-F dev=false \
-F platform="$platform" \
-F sourceMap=#"$platform-release-bundle.map" \
-F bundle=#"$platform-release.bundle" \
}
read_version () {
local tag=$1
local file=$2
echo "$(grep -m 1 $tag $file | grep -o '[0-9]\+\(\.[0-9]\+\)*')"
}
BUGSNAG_API_KEY=$(plutil -p ios/RVLife/Info.plist | grep BugsnagAPIKey | awk '{ print $3 }' | sed 's/"//g')
if [[ -z $BUGSNAG_API_KEY ]]; then
echo "Couldn't find bugsnag API key"
exit 1
fi
IOS_VERSION=$(read_version MARKETING_VERSION ios/RVLife.xcodeproj/project.pbxproj)
echo "iOS app version: $IOS_VERSION"
IOS_VERSION_CODE=$(read_version CURRENT_PROJECT_VERSION ios/RVLife.xcodeproj/project.pbxproj)
echo "iOS version code: $IOS_VERSION_CODE"
if [[ -z $IOS_VERSION || -z $IOS_VERSION_CODE ]]; then
echo "Couldn't get iOS app versions"
exit 1
fi
bundle ios
upload ios "$IOS_VERSION" "$IOS_VERSION_CODE"
echo ""
ANDROID_VERSION=$(read_version versionName android/app/build.gradle)
echo "Android app version: $ANDROID_VERSION"
ANDROID_VERSION_CODE=$(read_version versionCode android/app/build.gradle)
echo "Android version code: $ANDROID_VERSION_CODE"
if [[ -z $ANDROID_VERSION || -z $ANDROID_VERSION_CODE ]]; then
echo "Couldn't get Android app versions"
exit 1
fi
bundle android
upload android "$ANDROID_VERSION" "$ANDROID_VERSION_CODE"
I'm assuming I messed up some syntax or permissions or something somewhere, but can't seem to find the area I did. Any help is appreciated.
Difference between bash -x myScript and set -x on command line
Command Line
omz_termsupport_preexec:1> [[ '' == true ]]
+omz_termsupport_preexec:3> emulate -L zsh
+omz_termsupport_preexec:4> setopt extended_glob
+omz_termsupport_preexec:7> local -a cmdargs
+omz_termsupport_preexec:8> cmdargs=( curl https://upload.bugsnag.com/react-native-source-map -F -F -F -F -F - )
+omz_termsupport_preexec:10> [[ curl = fg ]]
+omz_termsupport_preexec:44> local CMD=curl
+omz_termsupport_preexec:45> local LINE='curl https://upload.bugsnag.com/react-native-source-map -F -F -F -F -F -'
+omz_termsupport_preexec:47> title '$CMD' '%100>...>$LINE%<<'
+title:1> emulate -L zsh
+title:2> setopt prompt_subst
+title:4> [[ '' == *term* ]]
+title:8> : '%100>...>$LINE%<<'
+title:10> case xterm-256color (cygwin | xterm*)
+title:12> print -Pn '\e]2;%100\>...\>\$LINE%\<\<\a'
+title:13> print -Pn '\e]1;\$CMD\a'
+-zsh:75> curl https://upload.bugsnag.com/react-native-source-map -F 'apiKey=API-KEY' -F 'appVersion=10.6.7’ -F 'appBundleVersion=4515' -F 'dev=false' -F 'platform=ios' -F 'sourceMap=#ios-release.bundle.map' -F 'bundle=#ios-release.bundle'
OK%
SH Script
+ upload ios 10.6.7 4515
+ platform=ios
+ version=10.6.7
+ version_code=4515
+ curl --http1.1 https://upload.bugsnag.com/react-native-source-map -F apiKey=API-KEY -F appVersion=10.6.7 -F appVersionCode=4515 -F dev=false -F platform=ios -F sourceMap=#ios-release-bundle.map -F bundle=#ios-release.bundle
curl: (26) Failed to open/read local data from file/application
+ echo ''
I have the following shell script, that does not compile:
#!/bin/sh
.....
.....
clean_up() {
echo "Clean up"
docker stop $KC_TEST_SVC
docker stop $KC_NAME
docker stop $POSTGRES_NAME
docker network rm $KC_NETWORK
}
# Check network if exists, if not then create
docker network inspect $KC_NETWORK
if [ $? -eq 1 ]; then
docker network create $KC_NETWORK
if [ $? -eq 1 ]; then
exit 1
fi
fi
docker run -d --rm --name $POSTGRES_NAME \
-e POSTGRES_DB=$POSTGRES_DB \
-e POSTGRES_USER=$POSTGRES_USER \
-e POSTGRES_PASSWORD=$POSTGRES_PW \
--network=$KC_NETWORK \
postgres:12.3
if [ $? -eq 1 ]; then
exit 1
fi
docker build --build-arg STAGE=int --tag $KC_TAG .
if [ $? -eq 1 ]; then
exit 1
fi
docker run -d --rm --name $KC_NAME \
-e DB_VENDOR=POSTGRES \
-e DB_ADDR=$POSTGRES_NAME \
-e DB_DATABASE=$POSTGRES_DB \
-e DB_USER=$POSTGRES_USER \
-e DB_PASSWORD=$POSTGRES_PW \
-e KEYCLOAK_USER=$KC_USER \
-e KEYCLOAK_PASSWORD=$KC_PW \
-e KEYCLOAK_LOGLEVEL=DEBUG \
--network=$KC_NETWORK \
$KC_TAG "-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir -Dkeycloak.migration.strategy=OVERWRITE_EXISTING"
if [ $? -eq 1 ]; then
exit 1
fi
# Wait until Keycloak get started
sleep 30
# Run test jetty service that is protected with Keycloak
docker run -d --rm --name $KC_TEST_SVC \
-v $(pwd)/app:/app \
--network $KC_NETWORK \
hub.databaker.io/devops/jetty-keycloak:0.1.6
if [ $? -eq 1 ]; then
exit 1
fi
# Request Tokens for credentials
KC_URL=http://$KC_SERVER/$KC_CONTEXT/realms/$KC_REALM/protocol/openid-connect/token
echo "Keycloak URL => $KC_URL"
echo "Test the client connection to Keycloak with user $KC_TEST_USER"
KC_RESPONSE=$(
docker run --rm --network=$KC_NETWORK curlimages/curl:7.71.1 -X POST \
-d "username=$KC_TEST_USER" \
-d "password=$KC_TEST_PW" \
-d "grant_type=password" \
-d "client_id=$KC_TEST_CLIENT" \
$KC_URL | docker run --rm -i stedolan/jq .
)
echo "Response from Keycloak $KC_RESPONSE"
if grep -q "error" <<< "$KC_RESPONSE"; then
echo "++++++++Error+++++++++"
exit 1
fi
KC_ACCESS_TOKEN=$(echo "$KC_RESPONSE" | docker run --rm -i stedolan/jq -r .access_token)
echo "Access token from KC => $KC_ACCESS_TOKEN"
echo "Make request to protected service"
SVC_URL=http://$KC_TEST_SVC:8080/api/health
SVC_RES=$(docker run --rm --network=$KC_NETWORK curlimages/curl:7.71.1 -v -k \
-H "Authorization: Bearer $KC_ACCESS_TOKEN" \
-H "Accept: application/json" \
$SVC_URL | docker run --rm -i stedolan/jq .status)
clean_up
echo "$SVC_RES"
if [ "$SVC_RES" != "I am healthy" ]; then
echo "Test failed."
exit 1
else
echo "Test was successful. The service response $SVC_RES."
fi
it complains:
Syntax error: redirection unexpected
due to of the following line:
if grep -q "error" <<< "$KC_RESPONSE"; then
echo "++++++++Error+++++++++"
exit 1
fi
#!/bin/sh does not support grep. How to rewrite it?
<<< is a here string and it's a bash extension. In posix shell, just pipe the data.
if printf "%s\n" "$KC_RESPONSE" | grep -q "error"; then
Do not do if [ $? -eq 1 ]; then, it's error prone. Do if ! command; then. (You might want to research set -eu).
Change #!/bin/sh to #!/bin/bash (ev. replace bash location, which bash helps to find location of bash, and to see if bash is installed), or you may need to rewrite your script in a portable way. In this case, create a temporary file, put the string in such file, redirect such file to grep (with single <), and then delete the temporary file.
With such long description, you see why there is an extension in bash, on the other hand, it is nearly a syntactic sugar: you can easily do the same.
I've a CoreOS cluster with three servers (on Digital Ocean), at this moment running MongoDB. Now I want to start Elasticsearch on this cluster with 1 replica (not using the Mongo river).
I followed the description as outlined here.
Resulting in two services, elasticsearch#.service & elasticsearch-discovery#.service.
elasticsearch#.service
[Unit]
Description=ElasticSearch service
After=etcd.service
After=docker.service
Before=elasticsearch-discovery#%i.service
Requires=elasticsearch-discovery#%i.service
[Service]
KillMode=none
TimeoutStartSec=0
TimeoutStopSec=360
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker kill %p-%i
ExecStartPre=-/usr/bin/docker rm %p-%i
ExecStartPre=-/usr/bin/bash -c "echo PreKill and rm done;"
ExecStartPre=/usr/bin/mkdir -p /data/elasticsearch
ExecStartPre=/usr/bin/docker pull dockerfile/elasticsearch
ExecStartPre=/usr/bin/bash -c "echo mkdir and docker pull done;"
ExecStart=/bin/bash -c "\
echo StartingUp; \
curl -f ${COREOS_PUBLIC_IPV4}:4001/v2/keys/services/elasticsearch; \
if [ $? = 0 ]; then \
UNICAST_HOSTS = $(etcdctl ls --recursive /services/elasticsearch | sed 's/\/services\/elasticsearch\///g' | sed 's/$/:9300/' | paste -s -d ','); \
echo Key found; \
else \
UNICAST_HOSTS=''; \
echo No Key found; \
fi;"
ExecStartPost=/bin/bash -c "\
echo Starting Docker; \
/usr/bin/docker run \
--name %p-%i \
--publish 9200:9200 \
--publish 9300:9300 \
--volume /data/elasticsearch:/data \
dockerfile/elasticsearch \
/elasticsearch/bin/elasticsearch \
--node.name=%p-%i \
--cluster.name=nvssearch \
--network.publish_host=${COREOS_PUBLIC_IPV4} \
--discovery.zen.ping.multicast.enabled=false \
--discovery.zen.ping.unicast.hosts=$UNICAST_HOSTS;"
ExecStop=/bin/bash/ -c "/usr/bin/docker kill %p-%i"
Restart=on-failure
[X-Fleet]
X-Conflicts=%p#*.service
elasticsearch-discovery#.service
[Unit]
Description=ElasticSearch discovery service
BindsTo=elasticsearch#%i.service
After=elasticsearch#%i.service
[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/bash -c '\
while true; do \
curl -f ${COREOS_PUBLIC_IPV4}:9200; \
if [ "$?" = "0" ]; then \
etcdctl set /services/elasticsearch/${COREOS_PUBLIC_IPV4} \ '{"http_port": 9200, "transport_port": 9300}\' --ttl 60; \
else \
etcdctl rm /services/elasticsearch/${COREOS_PUBLIC_IPV4}; \
fi; \
sleep 45; \
done'
ExecStop=/usr/bin.etcdctl rm /services/elasticsearch/${COREOS_PUBLIC_IPV4}
[X-Fleet]
X-ConditionMachineOf=elasticsearch#%i.service
But if I try to run the service (fleetctl submit / load / start elasticsearch#1.service), it immediately dies:
elasticsearch#1.service 475f6273.../IP inactive dead
Running fleetctl journal elasticsearch#1 results in the following message:
Mar 17 09:17:04 nvs-1 systemd[1]: Stopped ElasticSearch service.
That's all, no echoes I've added (to the service) are shown, or whatsoever. Anyone any ideas on how to get me further?
It is somewhat simpler to get Elasticsearch running with Weave. My blog post shows how to run it on Vagrant, however moving the same setup to cloud should be pretty straight-forward.
I've followed the same article you did and ran into the same issue. I tracked it down to the docker container not being available anymore, so I change the docker run command in the elasticsearch#service unit:
[Unit]
Description=ElasticSearch service
After=docker.service
Requires=docker.service
[Service]
TimeoutSec=180
EnvironmentFile=/etc/environment
ExecStartPre=/usr/bin/mkdir -p /data/elasticsearch
ExecStartPre=/usr/bin/docker pull elasticsearch
ExecStart=/bin/bash -c '\
curl -f ${COREOS_PRIVATE_IPV4}:4001/v2/keys/services/elasticsearch; \
if [ "$?" = "0" ]; then \
UNICAST_HOSTS=$(etcdctl ls --recursive /services/elasticsearch \
| sed "s/\/services\/elasticsearch\///g" \
| sed "s/$/:9300/" \
| paste -s -d","); \
else \
UNICAST_HOSTS=""; \
fi; \
/usr/bin/docker run \
--rm \
--name %p-%i \
--publish 9200:9200 \
--publish 9300:9300 \
--volume /data/elasticsearch:/data \
elasticsearch \
--node.name=%p-%i \
--cluster.name=logstash \
--network.publish_host=${COREOS_PRIVATE_IPV4} \
--discovery.zen.ping.multicast.enabled=false \
--discovery.zen.ping.unicast.hosts=$UNICAST_HOSTS'
ExecStop=/usr/bin/docker stop %p-%i
ExecStop=/usr/bin/docker rm %p-%i
[X-Fleet]
X-Conflicts=%p#*.service
Apart from that I think, on your original post, you're missing some quotes, double quotes and have some wrong blank spaces.
This is my current elastic-discovery#service for reference:
[Unit]
Description=ElasticSearch discovery service
BindsTo=elasticsearch#%i.service
[Service]
EnvironmentFile=/etc/environment
ExecStart=/bin/bash -c '\
while true; do \
curl -f ${COREOS_PRIVATE_IPV4}:9200; \
if [ "$?" = "0" ]; then \
etcdctl set /services/elasticsearch/${COREOS_PRIVATE_IPV4} \'{"http_port": 9200, "transport_port": 9300}\' --ttl 60; \
else \
etcdctl rm /services/elasticsearch/${COREOS_PRIVATE_IPV4}; \
fi; \
sleep 45; \
done'
ExecStop=/usr/bin/etcdctl rm /services/elasticsearch/${COREOS_PRIVATE_IPV4}
[X-Fleet]
X-ConditionMachineOf=elasticsearch#%i.service