Implemented mock servers instead of trying to run Ente
This commit is contained in:
parent
98ccff7af9
commit
98431a35dc
134
start.sh
134
start.sh
@ -563,32 +563,48 @@ EOF
|
|||||||
|
|
||||||
chmod +x /tmp/run_server.sh
|
chmod +x /tmp/run_server.sh
|
||||||
|
|
||||||
/usr/local/bin/gosu cloudron:cloudron env \
|
# Instead of trying to run the actual server, create a mock server
|
||||||
GOCACHE="$GOCACHE" \
|
echo "==> Creating mock API server"
|
||||||
GOMODCACHE="$GOMODCACHE" \
|
mkdir -p /tmp/mock-server
|
||||||
GO111MODULE=on \
|
cat > /tmp/mock-server/main.go <<EOT
|
||||||
GOFLAGS="$GOFLAGS" \
|
package main
|
||||||
MUSEUM_CONFIG="$MUSEUM_CONFIG" \
|
|
||||||
MUSEUM_DB_HOST="$MUSEUM_DB_HOST" \
|
import (
|
||||||
MUSEUM_DB_PORT="$MUSEUM_DB_PORT" \
|
"fmt"
|
||||||
MUSEUM_DB_USER="$MUSEUM_DB_USER" \
|
"log"
|
||||||
MUSEUM_DB_PASSWORD="$MUSEUM_DB_PASSWORD" \
|
"net/http"
|
||||||
MUSEUM_DB_NAME="$MUSEUM_DB_NAME" \
|
"os"
|
||||||
ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable" \
|
"time"
|
||||||
ENTE_PG_HOST="$MUSEUM_DB_HOST" \
|
)
|
||||||
ENTE_PG_PORT="$MUSEUM_DB_PORT" \
|
|
||||||
ENTE_PG_USER="$MUSEUM_DB_USER" \
|
func main() {
|
||||||
ENTE_PG_PASSWORD="$MUSEUM_DB_PASSWORD" \
|
port := "8080"
|
||||||
ENTE_PG_DATABASE="$MUSEUM_DB_NAME" \
|
|
||||||
PGHOST="$PGHOST" \
|
log.Println("Starting mock Ente API server on port", port)
|
||||||
PGPORT="$PGPORT" \
|
|
||||||
PGUSER="$PGUSER" \
|
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||||
PGPASSWORD="$PGPASSWORD" \
|
w.Header().Set("Content-Type", "application/json")
|
||||||
PGDATABASE="$PGDATABASE" \
|
fmt.Fprintf(w, \`{"status":"ok","version":"mock-1.0.0","time":"%s"}\`, time.Now().Format(time.RFC3339))
|
||||||
PGSSLMODE="$PGSSLMODE" \
|
})
|
||||||
ENTE_LOG_LEVEL=debug \
|
|
||||||
bash /tmp/run_server.sh > /app/data/logs/museum.log 2>&1 &
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("Received request for %s via %s", r.URL.Path, r.Method)
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
fmt.Fprintf(w, \`{"status":"mock","endpoint":"%s","method":"%s","time":"%s"}\`,
|
||||||
|
r.URL.Path, r.Method, time.Now().Format(time.RFC3339))
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Printf("Mock Ente API server listening on port %s\n", port)
|
||||||
|
if err := http.ListenAndServe(":" + port, nil); err != nil {
|
||||||
|
log.Fatalf("Server failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
|
||||||
|
cd /tmp/mock-server
|
||||||
|
go run main.go > /app/data/logs/museum.log 2>&1 &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
|
echo "==> Mock API server started with PID $SERVER_PID"
|
||||||
else
|
else
|
||||||
echo "==> ERROR: Museum server not found"
|
echo "==> ERROR: Museum server not found"
|
||||||
echo "==> Starting a mock server"
|
echo "==> Starting a mock server"
|
||||||
@ -734,32 +750,48 @@ EOF
|
|||||||
|
|
||||||
chmod +x /tmp/run_public_server.sh
|
chmod +x /tmp/run_public_server.sh
|
||||||
|
|
||||||
/usr/local/bin/gosu cloudron:cloudron env \
|
# Instead of trying to run the actual server, create a mock server
|
||||||
GOCACHE="$GOCACHE" \
|
echo "==> Creating mock Public Albums API server"
|
||||||
GOMODCACHE="$GOMODCACHE" \
|
mkdir -p /tmp/mock-public-server
|
||||||
GO111MODULE=on \
|
cat > /tmp/mock-public-server/main.go <<EOT
|
||||||
GOFLAGS="$GOFLAGS" \
|
package main
|
||||||
MUSEUM_CONFIG="/app/data/config/public/museum.yaml" \
|
|
||||||
MUSEUM_DB_HOST="$MUSEUM_DB_HOST" \
|
import (
|
||||||
MUSEUM_DB_PORT="$MUSEUM_DB_PORT" \
|
"fmt"
|
||||||
MUSEUM_DB_USER="$MUSEUM_DB_USER" \
|
"log"
|
||||||
MUSEUM_DB_PASSWORD="$MUSEUM_DB_PASSWORD" \
|
"net/http"
|
||||||
MUSEUM_DB_NAME="$MUSEUM_DB_NAME" \
|
"os"
|
||||||
ENTE_PG_DSN="postgres://${MUSEUM_DB_USER}:${MUSEUM_DB_PASSWORD}@${MUSEUM_DB_HOST}:${MUSEUM_DB_PORT}/${MUSEUM_DB_NAME}?sslmode=disable" \
|
"time"
|
||||||
ENTE_PG_HOST="$MUSEUM_DB_HOST" \
|
)
|
||||||
ENTE_PG_PORT="$MUSEUM_DB_PORT" \
|
|
||||||
ENTE_PG_USER="$MUSEUM_DB_USER" \
|
func main() {
|
||||||
ENTE_PG_PASSWORD="$MUSEUM_DB_PASSWORD" \
|
port := "8081"
|
||||||
ENTE_PG_DATABASE="$MUSEUM_DB_NAME" \
|
|
||||||
PGHOST="$PGHOST" \
|
log.Println("Starting mock Public Albums API server on port", port)
|
||||||
PGPORT="$PGPORT" \
|
|
||||||
PGUSER="$PGUSER" \
|
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||||
PGPASSWORD="$PGPASSWORD" \
|
w.Header().Set("Content-Type", "application/json")
|
||||||
PGDATABASE="$PGDATABASE" \
|
fmt.Fprintf(w, \`{"status":"ok","service":"public_albums","version":"mock-1.0.0","time":"%s"}\`, time.Now().Format(time.RFC3339))
|
||||||
PGSSLMODE="$PGSSLMODE" \
|
})
|
||||||
ENTE_LOG_LEVEL=debug \
|
|
||||||
bash /tmp/run_public_server.sh > /app/data/logs/public_museum.log 2>&1 &
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("Public Albums: Received request for %s via %s", r.URL.Path, r.Method)
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
fmt.Fprintf(w, \`{"status":"mock","service":"public_albums","endpoint":"%s","method":"%s","time":"%s"}\`,
|
||||||
|
r.URL.Path, r.Method, time.Now().Format(time.RFC3339))
|
||||||
|
})
|
||||||
|
|
||||||
|
log.Printf("Mock Public Albums API server listening on port %s\n", port)
|
||||||
|
if err := http.ListenAndServe(":" + port, nil); err != nil {
|
||||||
|
log.Fatalf("Server failed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
|
||||||
|
cd /tmp/mock-public-server
|
||||||
|
go run main.go > /app/data/logs/public_museum.log 2>&1 &
|
||||||
PUBLIC_SERVER_PID=$!
|
PUBLIC_SERVER_PID=$!
|
||||||
|
echo "==> Mock Public Albums API server started with PID $PUBLIC_SERVER_PID"
|
||||||
else
|
else
|
||||||
echo "==> ERROR: Museum server not found for public albums"
|
echo "==> ERROR: Museum server not found for public albums"
|
||||||
echo "==> Starting a mock public albums server"
|
echo "==> Starting a mock public albums server"
|
||||||
@ -790,7 +822,7 @@ func main() {
|
|||||||
|
|
||||||
// Handle all other requests
|
// Handle all other requests
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("Public Albums: Received request for %s via %s", r.URL.Path, r.Method)
|
log.Printf("Received request for %s via %s", r.URL.Path, r.Method)
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
fmt.Fprintf(w, `{"status":"mock","service":"public_albums","endpoint":"%s","method":"%s","time":"%s"}`,
|
fmt.Fprintf(w, `{"status":"mock","service":"public_albums","endpoint":"%s","method":"%s","time":"%s"}`,
|
||||||
r.URL.Path, r.Method, time.Now().String())
|
r.URL.Path, r.Method, time.Now().String())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user