-
-
Save vil1/5b4e37b03a1eb752bfb6 to your computer and use it in GitHub Desktop.
This file contains 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
# This recipe is intended to be run at the `configure` step | |
# | |
directory "/scripts" do | |
owner "root" | |
group "root" | |
action :create | |
end | |
template "/scripts/startup_node.sh" do | |
@cluster_size = node[:opsworks][:layers]['stag-es'][:instances].size() | |
source "startup_node.sh.erb" | |
user "root" | |
group "root" | |
mode "0777" | |
Chef::Log.debug("Cluster size #{@cluster_size} reached, building startup script...") | |
action :create | |
only_if { @cluster_size >= 3 } | |
notifies :run, 'execute[startup_eventstore_node]', :immediately | |
end | |
execute "startup_eventstore_node" do | |
instance_ip = node[:opsworks][:instance][:private_ip] | |
other_ips = node[:opsworks][:layers]['stag-es'][:instances].map{ |name, instance| instance[:private_ip]}.keep_if{|ip| ip != instance_ip} | |
gossip_seed = other_ips.map{ |ip| "#{ip}:2112"}.join(",") | |
user "root" | |
cwd "/scripts" | |
command "./startup_node.sh" | |
environment "GOSSIP_SEED" => "#{gossip_seed}" | |
Chef::Log.debug("Starting eventstore node with gossip seed #{gossip_seed}") | |
action :nothing | |
not_if '[ -f RUNNING_PID ]', :cwd => "/opt/#{node['eventstore']['installation_directory']}" | |
end |
This file contains 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
#!/bin/sh | |
export MONO_THREADS_PER_CPU=100 | |
daemonize -p RUNNING_PID -u root -c /opt/<%= node['eventstore']['installation_directory']%>/ \ | |
/opt/<%= node['eventstore']['installation_directory']%>/run-node.sh \ | |
--int-ip=<%= node['opsworks']['instance']['private_ip'] %> \ | |
--ext-ip=<%= node['opsworks']['instance']['private_ip'] %> \ | |
--gossip-seed=$GOSSIP_SEED \ | |
--discover-via-dns=false \ | |
--cluster-size=3 \ | |
--run-projections=all \ | |
--log=/var/data/logs \ | |
--db=/var/data/db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment