64 lines
1.3 KiB
Ruby
64 lines
1.3 KiB
Ruby
#
|
|
# Cookbook Name:: kosmos-ipfs
|
|
# Recipe:: kredits_pinner
|
|
#
|
|
|
|
node.override["nodejs"]["repo"] = "https://deb.nodesource.com/node_16.x"
|
|
|
|
include_recipe 'kosmos-nodejs'
|
|
|
|
app_name = "ipfs-pinner"
|
|
deploy_user = "ipfs"
|
|
deploy_group = "ipfs"
|
|
|
|
group deploy_group
|
|
|
|
app_path = "/opt/#{app_name}"
|
|
|
|
rsk_node_ip = search(:node, "role:rskj_testnet").first["knife_zero"]["host"]
|
|
rsk_rpc_url = "http://#{rsk_node_ip}:4444"
|
|
|
|
git app_path do
|
|
user deploy_user
|
|
group deploy_group
|
|
repository "https://gitea.kosmos.org/kredits/#{app_name}.git"
|
|
revision node['kosmos-ipfs']['kredits-pinner']['revision']
|
|
notifies :restart, "systemd_unit[#{app_name}.service]", :delayed
|
|
end
|
|
|
|
execute "npm install" do
|
|
cwd app_path
|
|
environment "HOME" => app_path
|
|
user deploy_user
|
|
end
|
|
|
|
service_env = {
|
|
'DEBUG' => 'ipfs-pinner'
|
|
}
|
|
|
|
systemd_unit "#{app_name}.service" do
|
|
content({
|
|
Unit: {
|
|
Description: app_name,
|
|
After: "ipfs.service"
|
|
},
|
|
|
|
Service: {
|
|
ExecStartPre: '/bin/sleep 5',
|
|
ExecStart: "/usr/bin/npm start -- --watch --rpc-url #{rsk_rpc_url}",
|
|
WorkingDirectory: app_path,
|
|
User: deploy_user,
|
|
Group: deploy_group,
|
|
Environment: service_env.map { |k, v| "'#{k}=#{v}'" },
|
|
Restart: 'always'
|
|
},
|
|
|
|
Install: {
|
|
WantedBy: 'multi-user.target'
|
|
}
|
|
})
|
|
verify false
|
|
triggers_reload true
|
|
action [:create, :enable, :start]
|
|
end
|