Fix Go compatibility and mock server issues
This commit is contained in:
parent
192ebd0b5d
commit
4b7fb0fd9c
52
start.sh
52
start.sh
@ -353,7 +353,9 @@ cd "$SERVER_DIR"
|
|||||||
export GOPATH=/app/data/go
|
export GOPATH=/app/data/go
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
# Set version compatibility flags
|
# Set version compatibility flags
|
||||||
export GOTOOLCHAIN=local
|
export GOTOOLCHAIN=auto
|
||||||
|
# Override version requirements
|
||||||
|
export GOFLAGS="-mod=mod"
|
||||||
# Create a temporary directory for Go module cache and build in writable area
|
# Create a temporary directory for Go module cache and build in writable area
|
||||||
export GOCACHE=/app/data/go/cache
|
export GOCACHE=/app/data/go/cache
|
||||||
export GOMODCACHE=/app/data/go/modcache
|
export GOMODCACHE=/app/data/go/modcache
|
||||||
@ -432,12 +434,14 @@ elif [ -d "$SERVER_DIR/cmd/museum" ]; then
|
|||||||
# Instead of modifying go.mod, set environment variables for compatibility
|
# Instead of modifying go.mod, set environment variables for compatibility
|
||||||
echo "==> Setting Go environment variables for compatibility"
|
echo "==> Setting Go environment variables for compatibility"
|
||||||
export GOFLAGS="-mod=mod"
|
export GOFLAGS="-mod=mod"
|
||||||
export GOTOOLCHAIN=local
|
# Explicitly skip version check
|
||||||
|
export GOTOOLCHAIN=auto
|
||||||
|
|
||||||
# For Wasabi specific settings
|
# For Wasabi specific settings
|
||||||
if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then
|
if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then
|
||||||
echo "==> Detected Wasabi S3 endpoint, adjusting settings"
|
echo "==> Detected Wasabi S3 endpoint, adjusting settings"
|
||||||
/usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 \
|
echo "==> Adding -mod=mod to go run to ignore version mismatch"
|
||||||
|
/usr/local/bin/gosu cloudron:cloudron go run -mod=mod cmd/museum/main.go --port 8000 \
|
||||||
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
||||||
--storage.s3.region="${S3_REGION}" \
|
--storage.s3.region="${S3_REGION}" \
|
||||||
--storage.s3.bucket="${S3_BUCKET}" \
|
--storage.s3.bucket="${S3_BUCKET}" \
|
||||||
@ -451,7 +455,7 @@ elif [ -d "$SERVER_DIR/cmd/museum" ]; then
|
|||||||
--database.sslmode="require" \
|
--database.sslmode="require" \
|
||||||
--log.level=debug > /app/data/logs/museum-server.log 2>&1 &
|
--log.level=debug > /app/data/logs/museum-server.log 2>&1 &
|
||||||
else
|
else
|
||||||
/usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 \
|
/usr/local/bin/gosu cloudron:cloudron go run -mod=mod cmd/museum/main.go --port 8000 \
|
||||||
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
||||||
--storage.s3.region="${S3_REGION}" \
|
--storage.s3.region="${S3_REGION}" \
|
||||||
--storage.s3.bucket="${S3_BUCKET}" \
|
--storage.s3.bucket="${S3_BUCKET}" \
|
||||||
@ -510,10 +514,10 @@ else
|
|||||||
# Instead of trying to modify go.mod, set environment variables for compatibility
|
# Instead of trying to modify go.mod, set environment variables for compatibility
|
||||||
echo "==> Setting Go environment variables for compatibility"
|
echo "==> Setting Go environment variables for compatibility"
|
||||||
export GOFLAGS="-mod=mod"
|
export GOFLAGS="-mod=mod"
|
||||||
export GOTOOLCHAIN=local
|
export GOTOOLCHAIN=auto
|
||||||
|
|
||||||
echo "==> Running main.go with Go"
|
echo "==> Running main.go with Go"
|
||||||
/usr/local/bin/gosu cloudron:cloudron go run main.go --port 8000 \
|
/usr/local/bin/gosu cloudron:cloudron go run -mod=mod main.go --port 8000 \
|
||||||
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
||||||
--storage.s3.region="${S3_REGION}" \
|
--storage.s3.region="${S3_REGION}" \
|
||||||
--storage.s3.bucket="${S3_BUCKET}" \
|
--storage.s3.bucket="${S3_BUCKET}" \
|
||||||
@ -558,44 +562,40 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// Set up a handler for the root path
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
fmt.Fprintf(w, "<html><body><h1>Ente Museum Server Error</h1>")
|
html := "<html><body><h1>Ente Museum Server Error</h1>"
|
||||||
fmt.Fprintf(w, "<p>The Ente Museum server could not be started due to compatibility issues.</p>")
|
html += "<p>The Ente Museum server could not be started due to compatibility issues.</p>"
|
||||||
fmt.Fprintf(w, "<p>Please check the logs for more information.</p>")
|
html += "<p>Please check the application logs for more information.</p>"
|
||||||
|
html += "</body></html>"
|
||||||
// Show log excerpts if available
|
fmt.Fprint(w, html)
|
||||||
if _, err := os.Stat("/app/data/logs/museum-server.log"); err == nil {
|
|
||||||
logs, err := os.ReadFile("/app/data/logs/museum-server.log")
|
|
||||||
if err == nil && len(logs) > 0 {
|
|
||||||
fmt.Fprintf(w, "<h2>Recent Log Output:</h2><pre>%s</pre>", logs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(w, "</body></html>")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add a health endpoint
|
// Add a health endpoint
|
||||||
http.HandleFunc("/api/health", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/api/health", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Write([]byte(`{"status": "error", "message": "Running in fallback mode"}`))
|
fmt.Fprint(w, `{"status":"error","message":"Running in fallback mode"}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Start the server
|
||||||
log.Println("Starting mock server on port 8000")
|
log.Println("Starting mock server on port 8000")
|
||||||
|
|
||||||
|
// Start in a goroutine to prevent blocking
|
||||||
|
server := &http.Server{Addr: ":8000"}
|
||||||
go func() {
|
go func() {
|
||||||
log.Fatal(http.ListenAndServe(":8000", nil))
|
if err := server.ListenAndServe(); err != nil {
|
||||||
|
log.Fatalf("Server error: %v", err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
EOT
|
EOT
|
||||||
cd /tmp/mock-server
|
|
||||||
|
|
||||||
# Set Go environment variables for compatibility with the mock server
|
# Make sure we're in the mock-server directory
|
||||||
export GOFLAGS="-mod=mod"
|
cd /tmp/mock-server
|
||||||
export GOTOOLCHAIN=local
|
|
||||||
|
|
||||||
go run main.go &
|
go run main.go &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user