Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| #!/bin/bash | |
| RUN_DIR=/var/vcap/sys/run/etcd | |
| PIDFILE=$RUN_DIR/etcd.pid | |
| WORK_DIR=/var/vcap/store/etcd | |
| JOB_DIR=/var/vcap/jobs/etcd | |
| source /var/vcap/packages/common/utils.sh | |
| case $1 in | |
| start) | |
| pid_guard $PIDFILE "etcd" | |
| mkdir -p $RUN_DIR | |
| mkdir -p $WORK_DIR | |
| chown -R vcap:vcap $RUN_DIR | |
| chown -R vcap:vcap $WORK_DIR | |
| /var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $JOB_DIR/config | |
| echo $$ > $PIDFILE | |
| <% my_ip = spec.networks.send(properties.networks.apps).ip %> | |
| <% my_host = spec.networks.send(properties.networks.apps).dns_record_name %> | |
| exec chpst -u vcap:vcap /var/vcap/packages/etcd/etcd -snapshot -data-dir=$WORK_DIR \ | |
| -addr=<%= my_ip %>:4001 \ | |
| -peer-addr=<%= my_ip %>:7001 \ | |
| -name=<%= "#{name}-#{spec.index}" %> \ | |
| <% | |
| # etcd crashes if all peers are missing. for the first deploy, | |
| # we need at least one instance to come up without trying to | |
| # connect to any peers. | |
| %> \ | |
| <% if p("etcd.machines").length > 1 %> \ | |
| <% if p("etcd.machines").first != my_ip && p("etcd.machines").first != my_host %> \ | |
| -peers=<%= p("etcd.machines").reject { |ip| ip == my_ip || ip == my_host }.map { |m| "#{m}:7001" }.join(",") %> \ | |
| <% end %> \ | |
| <% end %> \ | |
| -peer-heartbeat-timeout=<%= p("heartbeat_interval_in_milliseconds") %>\ | |
| -peer-election-timeout=<%= p("election_timeout_in_milliseconds") %> | |
| ;; | |
| stop) | |
| kill_and_wait $PIDFILE | |
| ;; | |
| *) | |
| echo "Usage: etcd_ctl {start|stop}" | |
| ;; | |
| esac |