Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ai.lemonade_server.Lemonade/lemonade-supervisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ for d in /app/extensions/backends/*/; do
[ -e "$d/lib/xrt" ] && export XILINX_XRT="$d"
done

# If the first argument is a command in the PATH, execute it directly
if [ $# -gt 0 ] && type -P "$1" >/dev/null 2>&1; then
exec "$@"
fi

# second launch / deep link: forward to the running app, then exit
LOCK="$XDG_RUNTIME_DIR/app/$FLATPAK_ID/supervisor.lock"
mkdir -p "$(dirname "$LOCK")"
Expand Down
19 changes: 19 additions & 0 deletions ai.lemonade_server.Lemonade/tests/supervisor/test_smoke.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ setup() {
export XDG_RUNTIME_DIR="$TMPROOT/run"
export FLATPAK_ID="ai.lemonade_server.Lemonade"
export LEMONADE_DATA_DIR="$TMPROOT/data"
export PATH="/app/bin:$PATH"
mkdir -p "$TMPROOT/run" "$TMPROOT/data" /app/bin
unset LEMONADE_FLATPAK_FORCE_BUNDLED LEMONADE_HOST LEMONADE_PORT
SUPERVISOR="$BATS_TEST_DIRNAME/../../lemonade-supervisor.sh"
Expand Down Expand Up @@ -123,3 +124,21 @@ teardown() {
wait_file "$TMPROOT/lemond.shutdown"
wait "$SUP" 2>/dev/null || true
}

@test "executes a command directly if it is in the PATH" {
cat > /app/bin/some-command <<EOF
#!/usr/bin/env bash
echo "\$@" > "$TMPROOT/some-command.argv"
EOF
chmod +x /app/bin/some-command

run "$SUPERVISOR" some-command arg1 arg2
[ "$status" -eq 0 ]
wait_file "$TMPROOT/some-command.argv"
[ "$(cat "$TMPROOT/some-command.argv")" = "arg1 arg2" ]

# Verify that lemond/tray/app were NOT started
[ ! -f "$TMPROOT/tray.pid" ]
[ ! -f "$TMPROOT/app.pid" ]
[ ! -f "$TMPROOT/lemond.argv" ]
}