Fix here-document syntax error in runtime config generation and Go module initialization
This commit is contained in:
parent
50a19a7908
commit
5dbbb094b4
32
start.sh
32
start.sh
@ -1071,9 +1071,10 @@ else
|
||||
cd /tmp/mock-server
|
||||
|
||||
# Initialize a proper Go module
|
||||
echo "==> Initializing Go module for mock API server"
|
||||
go mod init mock-server
|
||||
|
||||
# Write the program to a file
|
||||
# Write the program to a file with proper quoting
|
||||
cat > main.go << 'GOMOCK'
|
||||
package main
|
||||
|
||||
@ -1455,16 +1456,23 @@ func main() {
|
||||
}
|
||||
GOMOCK
|
||||
|
||||
# Unset any module-related flags before running standalone Go program
|
||||
# Completely unset Go module-related environment variables
|
||||
echo "==> Unsetting module flags before building mock server"
|
||||
unset GO111MODULE
|
||||
unset GOFLAGS
|
||||
unset GOMODCACHE
|
||||
unset GOPATH
|
||||
|
||||
# Build and run the mock server in the background
|
||||
echo "==> Building and starting mock API server on port 8080"
|
||||
ls -la
|
||||
|
||||
if go build -o mock_server; then
|
||||
# Show go.mod for debugging
|
||||
echo "==> Go module file contents:"
|
||||
cat go.mod
|
||||
|
||||
# Build the mock server (explicitly in current directory)
|
||||
if go build -o mock_server .; then
|
||||
echo "==> Successfully compiled mock API server"
|
||||
|
||||
# Create log directory if it doesn't exist
|
||||
@ -1478,7 +1486,7 @@ GOMOCK
|
||||
|
||||
# Wait to ensure the server is up
|
||||
echo "==> Waiting for server to start..."
|
||||
sleep 3
|
||||
sleep 5 # Increased sleep time for better reliability
|
||||
|
||||
# Check if the server is actually running
|
||||
if ps -p $SERVER_PID > /dev/null; then
|
||||
@ -1490,7 +1498,7 @@ GOMOCK
|
||||
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
|
||||
tail -n 30 /app/data/logs/mock_server.log
|
||||
fi
|
||||
else
|
||||
echo "==> ERROR: Mock API server failed to start"
|
||||
@ -1499,9 +1507,13 @@ GOMOCK
|
||||
fi
|
||||
else
|
||||
echo "==> ERROR: Failed to build mock API server"
|
||||
# Print Go version for debugging
|
||||
# Print Go version and current directory for debugging
|
||||
go version
|
||||
# Set a bogus server PID to prevent unbound variable error
|
||||
pwd
|
||||
ls -la
|
||||
echo "==> Current directory content:"
|
||||
cat main.go | head -10
|
||||
# Set a fallback value for SERVER_PID
|
||||
SERVER_PID=0
|
||||
fi
|
||||
fi
|
||||
@ -1865,7 +1877,7 @@ EOT
|
||||
# Create runtime-config.js files in writable locations
|
||||
echo "==> Creating runtime-config.js in writable location"
|
||||
mkdir -p /app/data/web
|
||||
cat > /app/data/web/runtime-config.js <<EOT
|
||||
cat > /app/data/web/runtime-config.js << 'EOT'
|
||||
// Runtime configuration for Ente
|
||||
window.ENTE_CONFIG = {
|
||||
API_URL: '${API_ENDPOINT}',
|
||||
@ -1894,6 +1906,10 @@ EOT
|
||||
console.log('PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL);
|
||||
EOT
|
||||
|
||||
# Update the variables in the runtime config
|
||||
sed -i "s|\${API_ENDPOINT}|${API_ENDPOINT}|g" /app/data/web/runtime-config.js
|
||||
sed -i "s|\${CLOUDRON_APP_ORIGIN}|${CLOUDRON_APP_ORIGIN}|g" /app/data/web/runtime-config.js
|
||||
|
||||
# Ensure runtime-config.js is readable
|
||||
chmod 644 /app/data/web/runtime-config.js
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user