diff --git a/cloud/entrypoint.sh b/cloud/entrypoint.sh index 2460616c..cd9ce43d 100644 --- a/cloud/entrypoint.sh +++ b/cloud/entrypoint.sh @@ -1,11 +1,21 @@ #!/bin/bash - +echo "TASK: Entrypoint script started" export MONGO_DB_DATA=$PYTHAGORA_DATA_DIR/mongodata mkdir -p $MONGO_DB_DATA # Start MongoDB in the background mongod --dbpath "$MONGO_DB_DATA" --bind_ip_all >> $MONGO_DB_DATA/mongo_logs.txt 2>&1 & +# Loop until MongoDB is running (use pgrep for speed) +echo "TASK: Starting MongoDB..." +for ((i=0; i<10*5; i++)); do + if pgrep -x mongod > /dev/null; then + echo "TASK: MongoDB started" + break + fi + sleep 0.2 +done + export DB_DIR=$PYTHAGORA_DATA_DIR/database chown -R devuser: $PYTHAGORA_DATA_DIR @@ -27,7 +37,7 @@ su -c "git config --global user.name 'pythagora'" devuser # Mark entrypoint as done su -c "touch /tmp/entrypoint.done" devuser -echo "Entrypoint script finished" +echo "FINISH: Entrypoint script finished" # Keep container running tail -f /dev/null diff --git a/cloud/on-event-extension-install.sh b/cloud/on-event-extension-install.sh index e32a5966..8f2a8985 100644 --- a/cloud/on-event-extension-install.sh +++ b/cloud/on-event-extension-install.sh @@ -15,9 +15,11 @@ CODE_SERVER_PID=$! echo $CODE_SERVER_PID > /tmp/vscode-http-server.pid # Wait for code-server to open the port (e.g., 8080) -until curl -s "http://localhost:$VSCODE_SERVER_PORT" > /dev/null; do - echo "Waiting for code-server to start..." - sleep 1 +for ((i=0; i<15*5; i++)); do + if curl -s "http://localhost:$VSCODE_SERVER_PORT" > /dev/null; then + echo "TASK: VS Code server started" + echo "VS Code HTTP server started with PID $CODE_SERVER_PID. Access at http://localhost:$VSCODE_SERVER_PORT" + break + fi + sleep 0.2 done - -echo "VS Code HTTP server started with PID $CODE_SERVER_PID. Access at http://localhost:$VSCODE_SERVER_PORT"