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'] repository node['btcpay']['repo']
revision node['btcpay']['revision'] revision node['btcpay']['revision']
action :sync action :sync
notifies :stop, "systemd_unit[btcpayserver.service]", :immediately notifies :stop, "service[btcpayserver]", :immediately
notifies :run, 'bash[build_btcpay]', :immediately notifies :run, 'bash[build_btcpay]', :immediately
end end
@ -22,7 +22,7 @@ bash 'build_btcpay' do
./build.sh ./build.sh
EOH EOH
action :nothing action :nothing
notifies :restart, "systemd_unit[btcpayserver.service]", :delayed notifies :restart, "service[btcpayserver]", :delayed
end end
directory "/home/#{node['bitcoin']['username']}/.btcpayserver" do directory "/home/#{node['bitcoin']['username']}/.btcpayserver" do
@ -58,7 +58,7 @@ template node['btcpay']['config_path'] do
postgres_user: node['btcpay']['postgres']['user'], postgres_user: node['btcpay']['postgres']['user'],
postgres_password: credentials['postgres_password'], postgres_password: credentials['postgres_password'],
lnd_admin_macaroon_path: lnd_admin_macaroon_path lnd_admin_macaroon_path: lnd_admin_macaroon_path
notifies :restart, "systemd_unit[btcpayserver.service]", :delayed notifies :restart, "service[btcpayserver]", :delayed
end end
directory '/run/btcpayserver' do directory '/run/btcpayserver' do
@ -73,6 +73,7 @@ if node["nbxplorer"]["postgres"]
nbxpg_database = node["nbxplorer"]["postgres"]["database"] 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" 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 end
systemd_unit 'btcpayserver.service' do systemd_unit 'btcpayserver.service' do
content({ content({
Unit: { Unit: {
@ -101,7 +102,11 @@ systemd_unit 'btcpayserver.service' do
}) })
verify false verify false
triggers_reload true triggers_reload true
action [:create, :enable, :start] action [:create]
end
service "btcpayserver" do
action [:enable, :start]
end end
firewall_rule "BTCPay API private access" do firewall_rule "BTCPay API private access" do