Skip to content

Instantly share code, notes, and snippets.

@cgswong
Created February 12, 2015 15:49
Show Gist options
  • Save cgswong/8544e150d189a609f473 to your computer and use it in GitHub Desktop.
Save cgswong/8544e150d189a609f473 to your computer and use it in GitHub Desktop.
Elasticsearch discovery Fleet service
[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/logging/es/${COREOS_PRIVATE_IPV4} \'{"http_port": 9200, "transport_port": 9300}\' --ttl 60; \
else \
etcdctl rm /services/logging/es/${COREOS_PRIVATE_IPV4}; \
fi; \
sleep 45; \
done'
ExecStop=/usr/bin/etcdctl rm /services/logging/es/${COREOS_PRIVATE_IPV4}
[X-Fleet]
MachineOf=elasticsearch@%i.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment