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
|
cd /tmp/mock-server
|
||||||
|
|
||||||
# Initialize a proper Go module
|
# Initialize a proper Go module
|
||||||
|
echo "==> Initializing Go module for mock API server"
|
||||||
go mod init mock-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'
|
cat > main.go << 'GOMOCK'
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@ -1455,16 +1456,23 @@ func main() {
|
|||||||
}
|
}
|
||||||
GOMOCK
|
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"
|
echo "==> Unsetting module flags before building mock server"
|
||||||
unset GO111MODULE
|
unset GO111MODULE
|
||||||
unset GOFLAGS
|
unset GOFLAGS
|
||||||
unset GOMODCACHE
|
unset GOMODCACHE
|
||||||
|
unset GOPATH
|
||||||
|
|
||||||
# Build and run the mock server in the background
|
# Build and run the mock server in the background
|
||||||
echo "==> Building and starting mock API server on port 8080"
|
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"
|
echo "==> Successfully compiled mock API server"
|
||||||
|
|
||||||
# Create log directory if it doesn't exist
|
# Create log directory if it doesn't exist
|
||||||
@ -1478,7 +1486,7 @@ GOMOCK
|
|||||||
|
|
||||||
# Wait to ensure the server is up
|
# Wait to ensure the server is up
|
||||||
echo "==> Waiting for server to start..."
|
echo "==> Waiting for server to start..."
|
||||||
sleep 3
|
sleep 5 # Increased sleep time for better reliability
|
||||||
|
|
||||||
# Check if the server is actually running
|
# Check if the server is actually running
|
||||||
if ps -p $SERVER_PID > /dev/null; then
|
if ps -p $SERVER_PID > /dev/null; then
|
||||||
@ -1490,7 +1498,7 @@ GOMOCK
|
|||||||
else
|
else
|
||||||
echo "==> WARNING: Mock API server doesn't appear to be listening on port 8080"
|
echo "==> WARNING: Mock API server doesn't appear to be listening on port 8080"
|
||||||
echo "==> Checking server logs:"
|
echo "==> Checking server logs:"
|
||||||
tail -n 20 /app/data/logs/mock_server.log
|
tail -n 30 /app/data/logs/mock_server.log
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "==> ERROR: Mock API server failed to start"
|
echo "==> ERROR: Mock API server failed to start"
|
||||||
@ -1499,9 +1507,13 @@ GOMOCK
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "==> ERROR: Failed to build mock API server"
|
echo "==> ERROR: Failed to build mock API server"
|
||||||
# Print Go version for debugging
|
# Print Go version and current directory for debugging
|
||||||
go version
|
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
|
SERVER_PID=0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -1865,7 +1877,7 @@ EOT
|
|||||||
# Create runtime-config.js files in writable locations
|
# Create runtime-config.js files in writable locations
|
||||||
echo "==> Creating runtime-config.js in writable location"
|
echo "==> Creating runtime-config.js in writable location"
|
||||||
mkdir -p /app/data/web
|
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
|
// Runtime configuration for Ente
|
||||||
window.ENTE_CONFIG = {
|
window.ENTE_CONFIG = {
|
||||||
API_URL: '${API_ENDPOINT}',
|
API_URL: '${API_ENDPOINT}',
|
||||||
@ -1894,6 +1906,10 @@ EOT
|
|||||||
console.log('PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL);
|
console.log('PUBLIC_ALBUMS_URL:', window.ENTE_CONFIG.PUBLIC_ALBUMS_URL);
|
||||||
EOT
|
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
|
# Ensure runtime-config.js is readable
|
||||||
chmod 644 /app/data/web/runtime-config.js
|
chmod 644 /app/data/web/runtime-config.js
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user