Skip to content

Instantly share code, notes, and snippets.

@kovkev
Created March 20, 2018 16:15
Show Gist options
  • Save kovkev/93d730e428c442377a967b099cd18c05 to your computer and use it in GitHub Desktop.
Save kovkev/93d730e428c442377a967b099cd18c05 to your computer and use it in GitHub Desktop.
Long running interactive processes
What is a nice solution for user defined long running
interactive processes that should ideally always be running?
I have this server which I want to sync a certain local
directory with. I want to do so when I am ssh'ed to the
server. The way I used to do it was spin up a unison job
locally, which would connect to the server's unison and
both processes would communicate the changes made locally.
Today, I instead spin up the unison job on the server.
It connects to a Reverse Tunnel on a certain port and
communicates with the local unison process to communicate
the changes made locally (on my laptop).
That is nice because most of the things related to that
specific project are self-contained in that remote
instance's tmux session: A jupyter notebook server runs
there, the psql database, the unison process. Locally I
simply use my IDE.
However, I need to start the unison command every time I ssh into that server.
I know that I could do `while true ; do unison command; done`,
but I would like to keep that abstracted away in the background,
such that I don't have to issue the `while true` command when I
first boot the instance or provision it.
I know about systemd, and I have found unison services:
https://gist.github.com/thunfischbrot/0b6a21a84f166c4fa74fc5df4a470b17
, but then I do not know if that can handle the use-case where
unison asks the user for his input. Sometimes, unison will find a
conflict between the local and remote versions of a file and will
ask the user to chose one of the two versions. Maybe systemd is not
the right tool for the job? Or maybe it is, but I just do not know
how to provide a systemd service with some user input. Is it possible to
"attach" to a systemd service?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment