Skip to content

Commit

Permalink
Add basic monitoring with ntfy to container startscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
luator committed Jan 21, 2025
1 parent 48ef912 commit 9e6e06f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 11 additions & 1 deletion comprl-hockey-game/comprl-hockey.def
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ from: ubuntu:24.04
echo "deb http://archive.ubuntu.com/ubuntu noble universe" >> /etc/apt/sources.list
apt-get update

apt-get install -y python3-dev python3-pip python3-full swig git
apt-get install -y curl python3-dev python3-pip python3-full swig git

git clone https://github.com/martius-lab/teamproject-competition-server \
--depth 1 -b "{{ COMPRL_GIT_BRANCH }}" /comprl
Expand All @@ -30,6 +30,7 @@ from: ubuntu:24.04

%environment
export COMPRL_CONFIG_PATH="/comprl-config/config.toml"
export NTFY_TOPIC="comprl-server-monitor"


%runscript
Expand All @@ -38,10 +39,14 @@ from: ubuntu:24.04


%startscript
curl -d "Start comprl.server" ntfy.sh/${NTFY_TOPIC}

. /venv/bin/activate
# assumes that the config is bound at that path
python -m comprl.server --config "${COMPRL_CONFIG_PATH}"

curl -H "Priority: urgent" -H "Tags: warning" -d "comprl.server terminated. Exit code: $?" ntfy.sh/${NTFY_TOPIC}


%help
Running the container with `instance start` will run the comprl server.
Expand All @@ -58,10 +63,15 @@ from: ubuntu:24.04
export AGENT_TYPE=strong

%appstart agent
curl -d "Start agent ${AGENT_TYPE}" ntfy.sh/${NTFY_TOPIC}

. /venv/bin/activate
cd /comprl/comprl-hockey-agent
python ./run_client.py --args --agent "${AGENT_TYPE}"

curl -H "Priority: urgent" -H "Tags: warning" -d "Agent terminated. Exit code: $?" ntfy.sh/${NTFY_TOPIC}


%apphelp agent
Run an example agent (using `apptainer instance start --app agent ...`).
You need to provide the access token via the environment variable
Expand Down
7 changes: 6 additions & 1 deletion comprl-web-reflex/comprl-web-reflex.def
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from: python:3.12
export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install -y git caddy redis-server
apt-get install -y git caddy redis-server curl

git clone https://github.com/martius-lab/teamproject-competition-server --depth 1 -b "{{ COMPRL_GIT_BRANCH }}" /comprl

Expand Down Expand Up @@ -49,9 +49,14 @@ from: python:3.12
%environment
export REDIS_URL=redis://localhost
export COMPRL_CONFIG_PATH="/comprl-config/config.toml"
export NTFY_TOPIC="comprl-server-monitor"

%startscript
curl -d "Start comprl web interface" ntfy.sh/${NTFY_TOPIC}

. /venv/bin/activate
redis-server --daemonize yes
cd /comprl/comprl-web-reflex
reflex run --env prod "$@"

curl -H "Priority: urgent" -H "Tags: warning" -d "comprl web interface terminated. Exit code: $?" ntfy.sh/${NTFY_TOPIC}

0 comments on commit 9e6e06f

Please sign in to comment.