Use a task for key exchanges
This commit is contained in:
parent
01ab1c1d54
commit
572ccd1ee8
|
@ -35,5 +35,5 @@ chronoscope-*.tar
|
|||
npm-debug.log
|
||||
/assets/node_modules/
|
||||
|
||||
# IDE files
|
||||
# Ignore IDE files.
|
||||
.elixir_ls/
|
||||
|
|
|
@ -15,9 +15,10 @@ defmodule Chronoscope.Application do
|
|||
{Finch, name: Chronoscope.Finch},
|
||||
# Start a worker by calling: Chronoscope.Worker.start_link(arg)
|
||||
# {Chronoscope.Worker, arg},
|
||||
{Task.Supervisor, name: Chronoscope.TaskSupervisor},
|
||||
Chronoscope.NTS.Client,
|
||||
# Start to serve requests, typically the last entry
|
||||
ChronoscopeWeb.Endpoint,
|
||||
Chronoscope.NTS.Client
|
||||
ChronoscopeWeb.Endpoint
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
|
|
|
@ -18,6 +18,6 @@ defmodule Chronoscope.NTS do
|
|||
end
|
||||
|
||||
def key_establishment(host, port) do
|
||||
GenServer.call(Client, {:key_establishment, %{host: host, port: port}})
|
||||
GenServer.call(Client, {:key_establishment, %{host: host, port: port}}, 10_000)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,8 +68,13 @@ defmodule Chronoscope.NTS.Client do
|
|||
end
|
||||
|
||||
defp current_data(server, now) do
|
||||
response =
|
||||
Chronoscope.TaskSupervisor
|
||||
|> Task.Supervisor.async(fn -> KeyEstablishmentClient.key_establishment(server) end)
|
||||
|> Task.await(10_000)
|
||||
|
||||
%{
|
||||
key_establishment_response: KeyEstablishmentClient.key_establishment(server),
|
||||
key_establishment_response: response,
|
||||
last_key_establishment: now
|
||||
}
|
||||
end
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
defmodule Mix.Tasks.Deploy do
|
||||
use Mix.Task
|
||||
|
||||
@moduledoc """
|
||||
Deploy this application to production.
|
||||
"""
|
||||
|
||||
@shortdoc "deploy to production"
|
||||
|
||||
@spec run([...]) :: any
|
||||
def run([host]) do
|
||||
System.cmd(
|
||||
"rsync",
|
||||
[
|
||||
"--archive",
|
||||
"--delete",
|
||||
"--compress",
|
||||
"--human-readable",
|
||||
"--progress",
|
||||
"--stats",
|
||||
"--verbose",
|
||||
"--exclude-from=.gitignore",
|
||||
"--exclude=.git/",
|
||||
"./",
|
||||
"#{host}:chronoscope/"
|
||||
],
|
||||
into: IO.stream()
|
||||
)
|
||||
|
||||
System.cmd("ssh", [host, "cd chronoscope && buildah build -t chronoscope:latest && podman auto-update"], into: IO.stream())
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue