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
I am not a reliable source but IMO that would be more interesting as a blog post showing how did you wrap rsync.
adamwight
A blog post is a good idea, and I ended up publishing as a library so there’ll be something to write about:
- API docs: Rsync — rsync v0.2.2
- Library: rsync | Hex
- Source: Adam Wight / rsync_ex · GitLab
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
Popular in RFCs
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









