Use service DSL

This commit is contained in:
Râu Cao 2023-02-08 15:31:17 +08:00
parent 99e029a5ca
commit bfdaac84a4
Signed by: raucao
GPG Key ID: 15E65F399D084BA9

View File

@ -11,7 +11,7 @@ git node['btcpay']['source_dir'] do
repository node['btcpay']['repo']
revision node['btcpay']['revision']
action :sync
notifies :stop, "systemd_unit[btcpayserver.service]", :immediately
notifies :stop, "service[btcpayserver]", :immediately
notifies :run, 'bash[build_btcpay]', :immediately
end
@ -22,7 +22,7 @@ bash 'build_btcpay' do
./build.sh
EOH
action :nothing
notifies :restart, "systemd_unit[btcpayserver.service]", :delayed
notifies :restart, "service[btcpayserver]", :delayed
end
directory "/home/#{node['bitcoin']['username']}/.btcpayserver" do
@ -58,7 +58,7 @@ template node['btcpay']['config_path'] do
postgres_user: node['btcpay']['postgres']['user'],
postgres_password: credentials['postgres_password'],
lnd_admin_macaroon_path: lnd_admin_macaroon_path
notifies :restart, "systemd_unit[btcpayserver.service]", :delayed
notifies :restart, "service[btcpayserver]", :delayed
end
directory '/run/btcpayserver' do
@ -73,6 +73,7 @@ if node["nbxplorer"]["postgres"]
nbxpg_database = node["nbxplorer"]["postgres"]["database"]
nbxpg_connect = "User ID=#{nbxpg_user};Password=#{nbxplorer_credentials['postgresql_password']};Database=#{nbxpg_database};Host=pg.kosmos.local;Port=5432;Application Name=btcpayserver;MaxPoolSize=80"
end
systemd_unit 'btcpayserver.service' do
content({
Unit: {
@ -101,7 +102,11 @@ systemd_unit 'btcpayserver.service' do
})
verify false
triggers_reload true
action [:create, :enable, :start]
action [:create]
end
service "btcpayserver" do
action [:enable, :start]
end
firewall_rule "BTCPay API private access" do