Add a systemd user service and installer for the stage simulator.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
20f018a523
commit
df05c8ca49
3 files changed
+85
No files matched your search
@@ -66,6 +66,20 @@ Options after the command go to the pad controller (for example `--lock-knobs`).
|
||||
`--no-enable` installs it without starting it at login (start it with
|
||||
`systemctl --user start padcontroller`). `--uninstall` removes the service. Logs: `journalctl --user -u padcontroller -f`.
|
||||
|
||||
## Stage simulator
|
||||
|
||||
`python -m simulator` listens for Art-Net on port 6454 and draws the rig at
|
||||
http://127.0.0.1:8765. It can run as a systemd user service the same way:
|
||||
|
||||
```bash
|
||||
simulator/systemd/install.sh
|
||||
```
|
||||
|
||||
Options after the command go to the simulator (for example `--show shows/test.qxw`).
|
||||
`--no-enable` installs it without starting it at login (start it with
|
||||
`systemctl --user start simulator`). `--uninstall` removes the service.
|
||||
Logs: `journalctl --user -u simulator -f`.
|
||||
|
||||
## Chataigne
|
||||
|
||||
`scripts/shows/make_chataigne.py` turns a show spec into a Chataigne project, so the
|
||||
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install the stage simulator as a systemd user service and start it.
|
||||
#
|
||||
# simulator/systemd/install.sh # install, enable, start
|
||||
# simulator/systemd/install.sh --show shows/test.qxw # pass options to the simulator
|
||||
# simulator/systemd/install.sh --no-enable # install only; start it with
|
||||
# # systemctl --user start simulator
|
||||
# simulator/systemd/install.sh --uninstall
|
||||
#
|
||||
# Logs: journalctl --user -u simulator -f
|
||||
set -euo pipefail
|
||||
|
||||
UNIT=simulator.service
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
ROOT="$(cd "$HERE/../.." && pwd)"
|
||||
DEST="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||
|
||||
if [[ "${1:-}" == "--uninstall" ]]; then
|
||||
systemctl --user disable --now "$UNIT" 2>/dev/null || true
|
||||
rm -f "$DEST/$UNIT"
|
||||
systemctl --user daemon-reload
|
||||
echo "Removed $UNIT."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PYTHON="$ROOT/.venv/bin/python"
|
||||
[[ -x "$PYTHON" ]] || PYTHON="$(command -v python3)"
|
||||
|
||||
ENABLE=1
|
||||
if [[ "${1:-}" == "--no-enable" ]]; then
|
||||
ENABLE=
|
||||
shift
|
||||
fi
|
||||
|
||||
ARGS="$*"
|
||||
mkdir -p "$DEST"
|
||||
sed -e "s|@ROOT@|$ROOT|g" -e "s|@PYTHON@|$PYTHON|g" -e "s|@ARGS@|$ARGS|g" \
|
||||
"$HERE/$UNIT" >"$DEST/$UNIT"
|
||||
|
||||
systemctl --user daemon-reload
|
||||
if [[ -z "$ENABLE" ]]; then
|
||||
# Undo an earlier enable, so it does not start at login here.
|
||||
systemctl --user disable "$UNIT" 2>/dev/null || true
|
||||
echo "Installed $DEST/$UNIT. It does not start at login."
|
||||
echo "Start it with: systemctl --user start simulator"
|
||||
exit 0
|
||||
fi
|
||||
systemctl --user enable "$UNIT"
|
||||
systemctl --user restart "$UNIT"
|
||||
echo "Installed $DEST/$UNIT and started it."
|
||||
systemctl --user --no-pager status "$UNIT" | head -5 || true
|
||||
@@ -0,0 +1,20 @@
|
||||
# Stage simulator (python -m simulator) as a systemd user service.
|
||||
# install.sh fills in @ROOT@, @PYTHON@ and @ARGS@ and copies it to
|
||||
# ~/.config/systemd/user/.
|
||||
|
||||
[Unit]
|
||||
Description=Stage simulator (Art-Net on 6454, view on http://127.0.0.1:8765)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=@ROOT@
|
||||
ExecStart=@PYTHON@ -m simulator @ARGS@
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
# The simulator shuts its server and Art-Net socket down on Ctrl+C.
|
||||
KillSignal=SIGINT
|
||||
Restart=on-failure
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
Reference in new issue
Block a user