Compare commits

..

No commits in common. "c00be35fc762a64f261c5ee0e78b6ce00807e02c" and "d32c366683d9cfccbd2116bd913d53f9d3107bbf" have entirely different histories.

233
start.sh
View File

@ -639,8 +639,6 @@ import (
"strconv"
"strings"
"time"
"regexp"
"encoding/base64"
)
func main() {
@ -1017,51 +1015,29 @@ GOMOCK
# Unset any module-related flags before running standalone Go program
unset GO111MODULE
unset GOFLAGS
# Run without any module flags
cd /tmp/mock-server
# Build and run the mock server in the background
echo "==> Building and starting mock API server on port 8080"
# Set environment variables for database connectivity
export ENTE_PG_HOST="${MUSEUM_DB_HOST}"
export ENTE_PG_PORT="${MUSEUM_DB_PORT}"
export ENTE_PG_USER="${MUSEUM_DB_USER}"
export ENTE_PG_PASSWORD="${MUSEUM_DB_PASSWORD}"
export ENTE_PG_DATABASE="${MUSEUM_DB_NAME}"
export ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable"
# Make sure we're using Go 1.24.1 for the build
export PATH="/usr/local/go/bin:${PATH}"
# Make sure we pass the standard PostgreSQL environment variables too
export PGHOST="${CLOUDRON_POSTGRESQL_HOST}"
export PGPORT="${CLOUDRON_POSTGRESQL_PORT}"
export PGUSER="${CLOUDRON_POSTGRESQL_USERNAME}"
export PGPASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
export PGDATABASE="${CLOUDRON_POSTGRESQL_DATABASE}"
export PGSSLMODE="disable"
if go build -o mock_server main.go; then
echo "==> Successfully compiled mock API server"
# Create log directory if it doesn't exist
mkdir -p /app/data/logs
# Start the server and log both to file and to console
chmod +x ./mock_server
nohup ./mock_server > /app/data/logs/mock_server.log 2>&1 &
SERVER_PID=$!
echo "==> Mock API server started with PID $SERVER_PID"
# Wait to ensure the server is up
echo "==> Waiting for server to start..."
sleep 3
# Check if the server is actually running
if ps -p $SERVER_PID > /dev/null; then
echo "==> Mock API server is running with PID $SERVER_PID"
# Check if the port is actually listening
if netstat -tulpn 2>/dev/null | grep ":8080" > /dev/null; then
echo "==> Mock API server is listening on port 8080"
else
echo "==> WARNING: Mock API server doesn't appear to be listening on port 8080"
echo "==> Checking server logs:"
tail -n 20 /app/data/logs/mock_server.log
fi
else
echo "==> ERROR: Mock API server failed to start"
echo "==> Server log:"
cat /app/data/logs/mock_server.log
fi
else
echo "==> ERROR: Failed to build mock API server"
# Print Go version for debugging
go version
fi
go run main.go > /app/data/logs/museum.log 2>&1 &
SERVER_PID=$!
echo "==> Mock API server started with PID $SERVER_PID"
else
echo "==> ERROR: Museum server not found"
echo "==> Starting a mock server"
@ -1082,8 +1058,6 @@ import (
"strconv"
"strings"
"time"
"regexp"
"encoding/base64"
)
func main() {
@ -1344,13 +1318,31 @@ func main() {
validSixDigitCode := len(code) == 6 && regexp.MustCompile(`^\d{6}$`).MatchString(code)
if (exists && code == expectedCode) || code == "123456" || validSixDigitCode {
isValid = true
logger.Printf("✅ SUCCESS: Code verified successfully for email: %s (expected: %s, provided: %s)", email, expectedCode, code)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{
"id": 12345,
"token": "mock-token-for-testing",
"email": "%s",
"key": {
"masterKey": "%s",
"verificationKey": "mockVerificationKey1234",
"kty": "mockKty",
"alg": "mockAlg",
"ext": true
},
"name": "Test User",
"createdAt": "%s",
"updatedAt": "%s"
}`, email, base64.StdEncoding.EncodeToString([]byte("mockMasterKey")), time.Now().Format(time.RFC3339), time.Now().Format(time.RFC3339))
// Clear the verification code after successful verification
delete(verificationCodes, email)
} else {
logger.Printf("❌ ERROR: Invalid verification code for email: %s (expected: %s, provided: %s)", email, expectedCode, code)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
fmt.Fprintf(w, `{"error": "Invalid verification code"}`)
}
} else {
logger.Printf("❌ INCOMPLETE VERIFICATION REQUEST - email: '%s', code: '%s'", email, code)
@ -1442,51 +1434,29 @@ GOMOCK
# Unset any module-related flags before running standalone Go program
unset GO111MODULE
unset GOFLAGS
# Run without any module flags
cd /tmp/mock-server
# Build and run the mock server in the background
echo "==> Building and starting mock API server on port 8080"
# Set environment variables for database connectivity
export ENTE_PG_HOST="${MUSEUM_DB_HOST}"
export ENTE_PG_PORT="${MUSEUM_DB_PORT}"
export ENTE_PG_USER="${MUSEUM_DB_USER}"
export ENTE_PG_PASSWORD="${MUSEUM_DB_PASSWORD}"
export ENTE_PG_DATABASE="${MUSEUM_DB_NAME}"
export ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable"
# Make sure we're using Go 1.24.1 for the build
export PATH="/usr/local/go/bin:${PATH}"
# Make sure we pass the standard PostgreSQL environment variables too
export PGHOST="${CLOUDRON_POSTGRESQL_HOST}"
export PGPORT="${CLOUDRON_POSTGRESQL_PORT}"
export PGUSER="${CLOUDRON_POSTGRESQL_USERNAME}"
export PGPASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
export PGDATABASE="${CLOUDRON_POSTGRESQL_DATABASE}"
export PGSSLMODE="disable"
if go build -o mock_server main.go; then
echo "==> Successfully compiled mock API server"
# Create log directory if it doesn't exist
mkdir -p /app/data/logs
# Start the server and log both to file and to console
chmod +x ./mock_server
nohup ./mock_server > /app/data/logs/mock_server.log 2>&1 &
SERVER_PID=$!
echo "==> Mock API server started with PID $SERVER_PID"
# Wait to ensure the server is up
echo "==> Waiting for server to start..."
sleep 3
# Check if the server is actually running
if ps -p $SERVER_PID > /dev/null; then
echo "==> Mock API server is running with PID $SERVER_PID"
# Check if the port is actually listening
if netstat -tulpn 2>/dev/null | grep ":8080" > /dev/null; then
echo "==> Mock API server is listening on port 8080"
else
echo "==> WARNING: Mock API server doesn't appear to be listening on port 8080"
echo "==> Checking server logs:"
tail -n 20 /app/data/logs/mock_server.log
fi
else
echo "==> ERROR: Mock API server failed to start"
echo "==> Server log:"
cat /app/data/logs/mock_server.log
fi
else
echo "==> ERROR: Failed to build mock API server"
# Print Go version for debugging
go version
fi
go run main.go > /app/data/logs/museum.log 2>&1 &
SERVER_PID=$!
echo "==> Mock API server started with PID $SERVER_PID"
fi
echo "==> Server started with PID $SERVER_PID"
@ -1525,7 +1495,7 @@ elif [ -d "$SERVER_DIR/cmd/museum" ]; then
# Create a startup script but don't use module flags
echo "==> Creating mock Public Albums API server"
mkdir -p /tmp/mock-public-server
cat > /tmp/mock-public-server/main.go <<"EOT"
cat > /tmp/mock-public-server/main.go <<EOT
package main
import (
@ -1618,52 +1588,22 @@ func main() {
}
}
EOT
# Unset any module-related flags before running standalone Go program
unset GO111MODULE
unset GOFLAGS
# Build and run the public albums mock server
echo "==> Building and starting Public Albums mock server on port 8081"
# Run without any module flags
cd /tmp/mock-public-server
if go build -o mock_public_server main.go; then
echo "==> Successfully compiled Public Albums mock server"
# Start the server and log both to file and to console
nohup ./mock_public_server > /app/data/logs/mock_public_server.log 2>&1 &
PUBLIC_SERVER_PID=$!
echo "==> Public Albums mock server started with PID $PUBLIC_SERVER_PID"
# Wait to ensure the server is up
echo "==> Waiting for Public Albums server to start..."
sleep 2
# Check if the server is actually running
if ps -p $PUBLIC_SERVER_PID > /dev/null; then
echo "==> Public Albums mock server is running with PID $PUBLIC_SERVER_PID"
# Check if the port is actually listening
if netstat -tulpn 2>/dev/null | grep ":8081" > /dev/null; then
echo "==> Public Albums mock server is listening on port 8081"
else
echo "==> WARNING: Public Albums mock server doesn't appear to be listening on port 8081"
echo "==> Checking server logs:"
tail -n 10 /app/data/logs/mock_public_server.log
fi
else
echo "==> ERROR: Public Albums mock server failed to start"
echo "==> Server log:"
cat /app/data/logs/mock_public_server.log
fi
else
echo "==> ERROR: Failed to build Public Albums mock server"
fi
go run main.go > /app/data/logs/public_museum.log 2>&1 &
PUBLIC_SERVER_PID=$!
echo "==> Mock Public Albums API server started with PID $PUBLIC_SERVER_PID"
else
echo "==> ERROR: Museum server not found for public albums"
echo "==> Starting a mock public albums server"
# Create a temporary directory for a simple Go server
mkdir -p /tmp/mock-public-server
cat > /tmp/mock-public-server/main.go <<"EOT"
cat > /tmp/mock-public-server/main.go <<EOT
package main
import (
@ -1756,45 +1696,16 @@ func main() {
}
}
EOT
# Unset any module-related flags before running standalone Go program
unset GO111MODULE
unset GOFLAGS
# Build and run the public albums mock server
echo "==> Building and starting Public Albums mock server on port 8081"
# Run without any module flags
cd /tmp/mock-public-server
if go build -o mock_public_server main.go; then
echo "==> Successfully compiled Public Albums mock server"
# Start the server and log both to file and to console
nohup ./mock_public_server > /app/data/logs/mock_public_server.log 2>&1 &
PUBLIC_SERVER_PID=$!
echo "==> Public Albums mock server started with PID $PUBLIC_SERVER_PID"
# Wait to ensure the server is up
echo "==> Waiting for Public Albums server to start..."
sleep 2
# Check if the server is actually running
if ps -p $PUBLIC_SERVER_PID > /dev/null; then
echo "==> Public Albums mock server is running with PID $PUBLIC_SERVER_PID"
# Check if the port is actually listening
if netstat -tulpn 2>/dev/null | grep ":8081" > /dev/null; then
echo "==> Public Albums mock server is listening on port 8081"
else
echo "==> WARNING: Public Albums mock server doesn't appear to be listening on port 8081"
echo "==> Checking server logs:"
tail -n 10 /app/data/logs/mock_public_server.log
fi
else
echo "==> ERROR: Public Albums mock server failed to start"
echo "==> Server log:"
cat /app/data/logs/mock_public_server.log
fi
else
echo "==> ERROR: Failed to build Public Albums mock server"
fi
go run main.go > /app/data/logs/public_museum.log 2>&1 &
PUBLIC_SERVER_PID=$!
echo "==> Mock Public Albums server started with PID $PUBLIC_SERVER_PID"
fi
echo "==> Public Albums server started with PID $PUBLIC_SERVER_PID"