1

runsvdir: UNIX init scheme with service supervision from runit is a nice tool to re-run some service(s) if it dies. It monitor a directory for changes, inotify like. It execute scripts in directories forever.

I have a structure like this:

$ tree app
app
├── service
│   ├── run
│   └── supervise
├── replay
│   ├── run
│   └── supervise
└── run
    ├── run
    └── supervise

What I would like to do is something like this, based on this in app/run/run and app/replay/run (I tried the solution in the link, but it fails):

su - user -c screen -S run<<EOF
[...]
# code
EOF

The code have to block/wait to avoid runsvdir to run multiple instances in //.

The code is run as root in a docker container. No systemd there.

I tested many solutions, have defuncts pids, of multiple processes in // that I want to avoid. I miss something maybe obvious.

Any idea?

  • debian 11 until next week ;)
  • runit 2.1.2-41

Note/Edit: it's not mandatory to create run/replay from init. It can be a shell script (bash). The screen's have to be run only one time.

2 Answers2

0

Fixed like this after docker build .:

docker exec -d -u mevatlave cont screen -d -m -S run ./run
docker exec -d -u mevatlave cont screen -d -m -S replay ./replay.sh
docker exec -it -u mevatlave cont screen -x run
-2

Spawning a user screen within a Docker container typically involves running an application that provides a graphical interface and connecting to it using a remote display protocol. Here's a general approach to achieving this:

Ensure that your Docker container has the necessary components installed to support a graphical environment. This includes a windowing system (such as Xorg) and a desktop environment or window manager (like XFCE, GNOME, or LXDE).

Start the Docker container with the appropriate flags to enable X11 forwarding and share the host's X server. For example:

docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix <image>

This command passes the environment variable DISPLAY from the host to the container and mounts the X server socket directory.

Install the desired application within the Docker container that provides the graphical interface. For instance, you could install a web browser like Firefox or a graphical text editor like gedit.

Launch the graphical application within the Docker container. For example:

firefox

Replace firefox with the actual command for the application you installed.

If everything is set up correctly, the graphical application should launch and appear on your host machine's screen. Note that you might need to configure X server permissions or disable access control on the host machine to allow connections from the Docker container. You can find out more blogs related to this topic at techkluster

  • 1
    screen here means something else than the answer implies. Please check the tags for the topic involved, and read the question more carefully – chexum Jun 19 '23 at 14:29