fix(goose): rename mai to mc, add initialization status

This commit is contained in:
2025-03-10 23:44:09 -06:00
parent 08ba1ab2da
commit 74c723db7b
7 changed files with 182 additions and 17 deletions

View File

@@ -20,16 +20,21 @@ RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/
# Create app directory
WORKDIR /app
# Install python dependencies
# This is done before copying scripts for better cache management
RUN pip install --no-cache-dir goose-ai langfuse
# Copy initialization scripts
COPY mai-init.sh /mai-init.sh
COPY mc-init.sh /mc-init.sh
COPY entrypoint.sh /entrypoint.sh
COPY mai-driver.yaml /mai-driver.yaml
COPY mc-driver.yaml /mc-driver.yaml
COPY init-status.sh /init-status.sh
# Make scripts executable
RUN chmod +x /mai-init.sh /entrypoint.sh
RUN chmod +x /mc-init.sh /entrypoint.sh /init-status.sh
# Install python dependencies
RUN pip install --no-cache-dir goose-ai langfuse
# Set up initialization status check on login
RUN echo '[ -x /init-status.sh ] && /init-status.sh' >> /etc/bash.bashrc
# Set up environment
ENV PYTHONUNBUFFERED=1

View File

@@ -2,7 +2,7 @@
# Entrypoint script for Goose driver
# Run the standard initialization script
/mai-init.sh
/mc-init.sh
# Start SSH server in the background
/usr/sbin/sshd

View File

@@ -0,0 +1,65 @@
#!/bin/bash
# Script to check and display initialization status
# Function to display initialization logs
show_init_logs() {
if [ -f "/init.log" ]; then
echo "Displaying initialization logs:"
echo "----------------------------------------"
cat /init.log
echo "----------------------------------------"
else
echo "No initialization logs found."
fi
}
# Function to follow logs until initialization completes
follow_init_logs() {
if [ ! -f "/init.log" ]; then
echo "No initialization logs found."
return
fi
echo "Initialization is still in progress. Showing logs:"
echo "----------------------------------------"
tail -f /init.log &
tail_pid=$!
# Check every second if initialization has completed
while true; do
if [ -f "/init.status" ] && grep -q "INIT_COMPLETE=true" "/init.status"; then
kill $tail_pid 2>/dev/null
echo "----------------------------------------"
echo "Initialization completed."
break
fi
sleep 1
done
}
# Check if we're in an interactive shell
if [ -t 0 ]; then
INTERACTIVE=true
else
INTERACTIVE=false
fi
# Check initialization status
if [ -f "/init.status" ]; then
if grep -q "INIT_COMPLETE=true" "/init.status"; then
echo "MC initialization has completed."
# No longer prompt to show logs when initialization is complete
else
echo "MC initialization is still in progress."
follow_init_logs
fi
else
echo "Cannot determine initialization status."
# Ask if user wants to see logs if they exist (only in interactive mode)
if [ -f "/init.log" ] && [ "$INTERACTIVE" = true ]; then
read -p "Do you want to see initialization logs? (y/n): " show_logs
if [[ "$show_logs" =~ ^[Yy] ]]; then
show_init_logs
fi
fi
fi

View File

@@ -4,7 +4,7 @@ version: 1.0.0
maintainer: team@monadical.com
init:
pre_command: /mai-init.sh
pre_command: /mc-init.sh
command: /entrypoint.sh
environment:

View File

@@ -1,6 +1,13 @@
#!/bin/bash
# Standardized initialization script for MC drivers
# Redirect all output to both stdout and the log file
exec > >(tee -a /init.log) 2>&1
# Mark initialization as started
echo "=== MC Initialization started at $(date) ==="
echo "INIT_COMPLETE=false" > /init.status
# Project initialization
if [ -n "$MC_PROJECT_URL" ]; then
echo "Initializing project: $MC_PROJECT_URL"
@@ -51,4 +58,8 @@ if [ -n "$LANGFUSE_SECRET_KEY" ] && [ -n "$LANGFUSE_PUBLIC_KEY" ]; then
export LANGFUSE_HOST="${LANGFUSE_HOST:-https://api.langfuse.com}"
fi
echo "MC driver initialization complete"
echo "MC driver initialization complete"
# Mark initialization as complete
echo "=== MC Initialization completed at $(date) ==="
echo "INIT_COMPLETE=true" > /init.status