mirror of
https://github.com/plausible/analytics.git
synced 2024-12-24 01:54:34 +03:00
Don't fail oban job when provision_ssl_certificates fails
This commit is contained in:
parent
718aff1bdf
commit
07653079e8
@ -23,7 +23,7 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
|
|||||||
)
|
)
|
||||||
|
|
||||||
for domain <- recent_custom_domains do
|
for domain <- recent_custom_domains do
|
||||||
{:ok, res, code} =
|
res =
|
||||||
ssh.run(
|
ssh.run(
|
||||||
conn,
|
conn,
|
||||||
'sudo certbot certonly --webroot -w /root/webroot -n -d \"#{domain.domain}\"',
|
'sudo certbot certonly --webroot -w /root/webroot -n -d \"#{domain.domain}\"',
|
||||||
@ -31,7 +31,13 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
|
|||||||
exec_timeout: @timeout
|
exec_timeout: @timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
report_result({res, code}, domain)
|
case res do
|
||||||
|
{:ok, msg, code} ->
|
||||||
|
report_result({msg, code}, domain)
|
||||||
|
|
||||||
|
e ->
|
||||||
|
Logger.warn("Error obtaining SSL certificate for #{domain.domain}: #{inspect(e)}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
|
@ -46,4 +46,18 @@ defmodule Plausible.Workers.SslCertificatesTest do
|
|||||||
domain = Repo.get_by(Plausible.Site.CustomDomain, site_id: site.id)
|
domain = Repo.get_by(Plausible.Site.CustomDomain, site_id: site.id)
|
||||||
refute domain.has_ssl_certificate
|
refute domain.has_ssl_certificate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "does not set has_ssl_certficate=true if the ssh command errors completely" do
|
||||||
|
site = insert(:site)
|
||||||
|
insert(:custom_domain, site: site, domain: "custom-site.com")
|
||||||
|
|
||||||
|
ssh_stub =
|
||||||
|
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|
||||||
|
|> stub(:run, fn _conn, _cmd, _opts -> {:error, "msg"} end)
|
||||||
|
|
||||||
|
ProvisionSslCertificates.perform(nil, ssh_stub)
|
||||||
|
|
||||||
|
domain = Repo.get_by(Plausible.Site.CustomDomain, site_id: site.id)
|
||||||
|
refute domain.has_ssl_certificate
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user