Optimize github build workflow

This commit is contained in:
Karmaa
2025-03-16 20:32:06 -05:00
parent faa60692e7
commit 0ccf3b42e4
3 changed files with 67 additions and 56 deletions

View File

@@ -2,19 +2,19 @@
set -e
# Create MongoDB pid directory if it doesn't exist
mkdir -p /var/run/mongodb
chown mongodb:mongodb /var/run/mongodb
mkdir -p /var/run/mongodb /data/db /var/log/mongodb
chown -R mongodb:mongodb /var/run/mongodb /data/db /var/log/mongodb
# Start MongoDB
# Start MongoDB (first without --fork to see errors)
echo "Starting MongoDB..."
mongod --fork --dbpath $MONGODB_DATA_DIR --logpath $MONGODB_LOG_DIR/mongodb.log --pidfilepath /var/run/mongodb/mongod.pid
gosu mongodb mongod --dbpath $MONGODB_DATA_DIR --logpath $MONGODB_LOG_DIR/mongodb.log &
MONGO_PID=$!
# Wait for MongoDB to be ready (using mongo instead of mongosh for MongoDB 4.4)
# Wait for MongoDB to be ready
echo "Waiting for MongoDB to start..."
until mongo --eval "print(\"waited for connection\")" > /dev/null 2>&1; do
until gosu mongodb mongo --eval "print(\"waited for connection\")" > /dev/null 2>&1; do
sleep 0.5
# Check if MongoDB is still running
if ! pgrep -x "mongod" > /dev/null; then
if ! kill -0 $MONGO_PID 2>/dev/null; then
echo "MongoDB failed to start. Checking logs:"
cat $MONGODB_LOG_DIR/mongodb.log
exit 1
@@ -26,16 +26,17 @@ echo "MongoDB has started"
echo "Starting nginx..."
nginx
# Change to app directory
# Change to app directory and ensure permissions
cd /app
chown -R node:node /app
# Start the SSH service
echo "Starting SSH service..."
node src/backend/ssh.cjs &
gosu node node src/backend/ssh.cjs &
# Start the database service
echo "Starting database service..."
node src/backend/database.cjs &
gosu node node src/backend/database.cjs &
# Keep the container running and show MongoDB logs
echo "All services started. Tailing MongoDB logs..."