Supports installing multiple instances of Parity on the same machine, running on different ports Refs #15
51 lines
1.2 KiB
Ruby
51 lines
1.2 KiB
Ruby
provides :parity_node
|
|
|
|
property :name, String, name_property: true
|
|
property :config, Hash
|
|
|
|
action :enable do
|
|
node_name = name
|
|
|
|
base_path = "#{node['kosmos-parity']['home_path']}/.local/share/io.parity.ethereum/#{name}"
|
|
|
|
directory base_path do
|
|
recursive true
|
|
owner "parity"
|
|
group "parity"
|
|
end
|
|
|
|
%w(chains keys).each do |subfolder|
|
|
directory "#{base_path}/#{subfolder}" do
|
|
recursive true
|
|
owner "parity"
|
|
group "parity"
|
|
end
|
|
end
|
|
|
|
config_file = "#{base_path}/config.toml"
|
|
|
|
template config_file do
|
|
source "config.toml.erb"
|
|
owner "parity"
|
|
group "parity"
|
|
variables config.merge(base_path: base_path)
|
|
end
|
|
|
|
execute "systemctl daemon-reload" do
|
|
command "systemctl daemon-reload"
|
|
action :nothing
|
|
end
|
|
|
|
parity_service = "parity_#{node_name}"
|
|
template "/lib/systemd/system/#{parity_service}.service" do
|
|
source "parity.systemd.service.erb"
|
|
variables config_file: config_file
|
|
notifies :run, "execute[systemctl daemon-reload]", :delayed
|
|
notifies :restart, "service[#{parity_service}]", :delayed
|
|
end
|
|
|
|
service parity_service do
|
|
action [:enable, :start]
|
|
end
|
|
end
|