Created
March 13, 2015 21:59
-
-
Save ianblenke/a0cdb2e6887cd2d2a90b to your computer and use it in GitHub Desktop.
Rethink-DB CoreOS cloud-init
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
coreos: | |
units: | |
- name: rethinkdb-create-fleet-units.service | |
command: start | |
content: | | |
[Unit] | |
After=docker.service | |
ConditionFileIsExecutable=/srv/rethinkdb-create-fleet-units.sh | |
ConditionFileNotEmpty=/srv/[email protected] | |
[Service] | |
ExecStart=/srv/rethinkdb-create-fleet-units.sh | |
RemainAfterExit=no | |
Type=oneshot | |
write_files: | |
- path: /srv/rethinkdb-create-fleet-units.sh | |
permissions: '0755' | |
owner: root | |
content: | | |
#!/bin/bash | |
source /etc/environment | |
set -ex | |
mkdir -p /etc/ecs | |
cp /srv/[email protected] /srv/rethinkdb-discovery@$(hostname).service | |
cp /srv/[email protected] /srv/rethinkdb@$(hostname).service | |
sed -i -e "s/%i/$(hostname)/" /srv/rethinkdb@$(hostname).service /srv/rethinkdb-discovery@$(hostname).service | |
( echo -n MachineID=; cat /etc/machine-id ) >> /srv/rethinkdb-discovery@$(hostname).service | |
( echo -n MachineID=; cat /etc/machine-id ) >> /srv/rethinkdb@$(hostname).service | |
/usr/bin/fleetctl start /srv/rethinkdb-discovery@$(hostname).service | |
/usr/bin/fleetctl start /srv/rethinkdb@$(hostname).service | |
- path: /srv/[email protected] | |
permissions: 0644 | |
owner: root | |
content: | | |
[Unit] | |
Description=Announce rethinkdb-discovery@%i | |
[Service] | |
EnvironmentFile=/etc/environment | |
ExecStart=/bin/sh -c "while true; do etcdctl set /announce/services/rethinkdb%i ${COREOS_PRIVATE_IPV4} --ttl 60; sleep 45; done" | |
ExecStop=/usr/bin/etcdctl rm /announce/services/rethinkdb%i | |
[X-Fleet] | |
- path: /srv/[email protected] | |
permissions: 0644 | |
owner: root | |
content: | | |
[Unit] | |
Description=Run the rethinkdb@%i database service | |
After=docker.service | |
BindsTo=rethinkdb-discovery@%i.service | |
[Service] | |
EnvironmentFile=/etc/environment | |
TimeoutStartSec=0 | |
ExecStartPre=-/usr/bin/docker kill rethinkdb | |
ExecStartPre=-/usr/bin/docker rm rethinkdb | |
ExecStartPre=-/usr/bin/mkdir -p /data/rethinkdb | |
ExecStartPre=/usr/bin/docker pull rethinkdb | |
ExecStart=/bin/sh -c '/usr/bin/docker run --name rethinkdb \ | |
-p ${COREOS_PRIVATE_IPV4}:18080:18080 \ | |
-p ${COREOS_PRIVATE_IPV4}:28015:28015 \ | |
-p ${COREOS_PRIVATE_IPV4}:29015:29015 \ | |
-v /data/rethinkdb/:/data/ \ | |
rethinkdb rethinkdb --bind all \ | |
--http-port 18080 \ | |
--canonical-address ${COREOS_PRIVATE_IPV4} \ | |
$(/usr/bin/etcdctl ls /announce/services | \ | |
xargs -I {} /usr/bin/etcdctl get {} | \ | |
sed s/^/"--join "/ | sed s/$/":29015"/ | \ | |
tr "\n" " ")' | |
ExecStop=/usr/bin/docker stop rethinkdb | |
[X-Fleet] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment