adamwight

adamwight

Any interest in a library that wraps rsync?

I’ve written a crude module for retrieving files from a remote server using rsync, since I didn’t see any existing tools already. This could be useful anywhere one needs to efficiently move files across filesystem or network boundaries, and could even be used for better control and monitoring of deployments. Does it sound like something I should package into a library?

The inner logic takes advantage of the --info=progress2 reporting mode for rsync, reading status lines to monitor progress:

port = Port.open(
  {:spawn_executable, System.find_executable("rsync")},
  [args: ["-a", "--info=progress2"] ++ remote_urls ++ [local_path],
    :binary, :exit_status, :hide, :use_stdio, :stderr_to_stdout]
)

receive do
  {^port, {:data, data}} ->
    ....

  {^port, {:exit_status, status}} ->
    ....
end

Most Liked

dimitarvp

dimitarvp

I am not a reliable source but IMO that would be more interesting as a blog post showing how did you wrap rsync.

adamwight

adamwight

A blog post is a good idea, and I ended up publishing as a library so there’ll be something to write about:

akash-akya

akash-akya

since the OS PID mapping is strictly internal and can’t be accessed from code.

BEAM does return OS PID: erlang — OTP 29.0.2 (erts 17.0.2)

iex> port = Port.open({:spawn_executable, "/usr/bin/cat"}, [])
#Port<0.11>

iex> {:os_pid, pid} = Port.info(port, :os_pid)
{:os_pid, 367095}

iex> {output, 0} = System.cmd("ps", [to_string(pid)], into: IO.stream())
    PID TTY      STAT   TIME COMMAND
 367095 ?        Ss     0:00 /usr/bin/cat

Where Next?

Popular in RFCs Top

wolf4earth
Every protocol you’ve shipped assumes the spec doesn’t change during the connection. This one doesn’t. Code is typed, composable, content...
New
laibulle
Hello, I am playing with quantitative finance with Elixir. This library is more a way for me to explore and learn in this area and especi...
New
zachallaun
Note: There are a few folks I’d really love to hear from, time permitting. Pinging in case the title isn’t catchy enough :slight_smile: @...
New
zachallaun
Hey gang, I’ve been using Req as my primary client for a project I’ve been working on that interacts with a number of APIs, and I quickl...
New
wingyplus
Hi, I start working on the fork version of Elixir GRPC. What I’ve done is the past few days: Support Elixir 1.11+ Support OTP 23+ OTP...
New
christhekeele
TL;DR: I’m planning on building a library, inspired by Vapor, to make configuring Elixir applications more straight-forward; in an approa...
New
noizu
Hello, I wrote a more comprehensive llama_cpp nif wrapper noizu-labs-ml/ex_llama: (github.com) inspired by the unfortunately doa jereg...
New
weakwire
Hello people, Big fan of elixir &amp; phoenix LiveView. While designing LiveView applications I use LiveComponent extensively. Issue-I...
New
blubparadox
Hi all. If you’ve looked on Twitter or YouTube you’ve seen the 1 billion row challenge, usually done in Java. I’ve written an Elixir vers...
New
marick
TL;DR I’ve forked the Lens package, changed the API some, added new lens makers and – most importantly – added a ton of documentation. In...
New

Other popular topics Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36432 110
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement