Increase ssh timeout in certbot call

pull/941/head
Uku Taht 6 years ago
parent 9de0902038
commit 70cc25e8cd

@ -2,6 +2,7 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
use Plausible.Repo
use Oban.Worker, queue: :provision_ssl_certificates, max_attempts: 1
require Logger
@timeout 20_000
@impl Oban.Worker
def perform(_args, _job, ssh \\ SSHEx) do
@ -25,7 +26,9 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
{:ok, res, code} =
ssh.run(
conn,
'sudo certbot certonly --webroot -w /root/webroot -n -d \"#{domain.domain}\"'
'sudo certbot certonly --webroot -w /root/webroot -n -d \"#{domain.domain}\"',
channel_timeout: @timeout,
exec_timeout: @timeout
)
report_result({res, code}, domain)

@ -9,13 +9,13 @@ defmodule Plausible.Workers.SslCertificatesTest do
ssh_stub =
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|> stub(:run, fn _conn, _cmd -> {:ok, "", 0} end)
|> stub(:run, fn _conn, _cmd, _opts -> {:ok, "", 0} end)
ProvisionSslCertificates.perform(nil, nil, ssh_stub)
assert_receive(
{SSHEx, :run,
[nil, 'sudo certbot certonly --webroot -w /root/webroot -n -d "custom-site.com"']}
[nil, 'sudo certbot certonly --webroot -w /root/webroot -n -d "custom-site.com"', _]}
)
end
@ -25,7 +25,7 @@ defmodule Plausible.Workers.SslCertificatesTest do
ssh_stub =
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|> stub(:run, fn _conn, _cmd -> {:ok, "", 0} end)
|> stub(:run, fn _conn, _cmd, _opts -> {:ok, "", 0} end)
ProvisionSslCertificates.perform(nil, nil, ssh_stub)
@ -39,7 +39,7 @@ defmodule Plausible.Workers.SslCertificatesTest do
ssh_stub =
stub(SSHEx, :connect, fn _cmd -> {:ok, nil} end)
|> stub(:run, fn _conn, _cmd -> {:ok, "", 1} end)
|> stub(:run, fn _conn, _cmd, _opts -> {:ok, "", 1} end)
ProvisionSslCertificates.perform(nil, nil, ssh_stub)

Loading…
Cancel
Save