From 0b47db62fedb16e970f1bfb91749530025a77752 Mon Sep 17 00:00:00 2001 From: pmeinhardt Date: Mon, 25 Feb 2019 23:47:22 +0100 Subject: [PATCH] Draft updated API with connection re-use --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a307164..2e2f29a6 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,19 @@ repeatable way, e.g. in the context of deployment tools: hosts = ["1.eg.io", {"2.eg.io", port: 2222}] context = - SSHKit.context(hosts) + SSHKit.context() |> SSHKit.path("/var/www/phx") |> SSHKit.user("deploy") |> SSHKit.group("deploy") |> SSHKit.umask("022") |> SSHKit.env(%{"NODE_ENV" => "production"}) -:ok = SSHKit.upload(context, ".", recursive: true) -:ok = SSHKit.run(context, "yarn install") +{:ok, conn} = SSHKit.connect(hosts) + +{:ok, conn} = SSHKit.upload(conn, context, ".", recursive: true) +{:ok, conn} = SSHKit.run(conn, context, "yarn install") + +{:ok, _} = SSHKit.close(conn) ``` The [`SSHKit`](https://hexdocs.pm/sshkit/SSHKit.html) module documentation has