Fixed git integration
This commit is contained in:
parent
6f4fc38d7c
commit
f0c878f67e
2 changed files with 10 additions and 8 deletions
|
@ -7,6 +7,7 @@ services:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: your-app-image:latest
|
image: your-app-image:latest
|
||||||
command: ["/app"]
|
command: ["/app"]
|
||||||
|
pull_policy: build
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
environment:
|
environment:
|
||||||
|
@ -22,10 +23,3 @@ services:
|
||||||
- SPOTIFY_CLIENT_SECRET=$SPOTIFY_CLIENT_SECRET
|
- SPOTIFY_CLIENT_SECRET=$SPOTIFY_CLIENT_SECRET
|
||||||
- SPOTIFY_REFRESH_TOKEN=$SPOTIFY_REFRESH_TOKEN
|
- SPOTIFY_REFRESH_TOKEN=$SPOTIFY_REFRESH_TOKEN
|
||||||
- STRIPE_SECRET_KEY=$STRIPE_SECRET_KEY
|
- STRIPE_SECRET_KEY=$STRIPE_SECRET_KEY
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.site.rule=Host(`atri.dad`)"
|
|
||||||
- "traefik.http.routers.site.service=site"
|
|
||||||
- "traefik.http.routers.site.entrypoints=websecure"
|
|
||||||
- "traefik.http.routers.site.tls.certresolver=letsencrypt"
|
|
||||||
- "traefik.http.services.site.loadbalancer.server.port=3000"
|
|
||||||
|
|
10
lib/sse.go
10
lib/sse.go
|
@ -99,27 +99,34 @@ func HandleIncomingMessages(c echo.Context, pubsub pubsub.PubSubMessage, client
|
||||||
var mutex sync.Mutex
|
var mutex sync.Mutex
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
// Receive messages using the context of the request, which is cancelled when the client disconnects
|
||||||
msg, err := pubsub.ReceiveMessage(c.Request().Context())
|
msg, err := pubsub.ReceiveMessage(c.Request().Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == context.Canceled {
|
if err == context.Canceled {
|
||||||
// The client has disconnected. Stop trying to send messages.
|
// Log when the client disconnects and stop the message forwarding
|
||||||
|
LogInfo.Printf("Client disconnected, stopping message forwarding")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Log errors other than client disconnection
|
||||||
LogError.Printf("Failed to receive message: %v", err)
|
LogError.Printf("Failed to receive message: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepare the data string to be sent as an SSE
|
||||||
data := fmt.Sprintf("data: %s\n\n", msg.Payload)
|
data := fmt.Sprintf("data: %s\n\n", msg.Payload)
|
||||||
|
|
||||||
|
// Locking before writing to the response writer to avoid concurrent write issues
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
if c.Response().Writer != nil {
|
if c.Response().Writer != nil {
|
||||||
_, err := c.Response().Write([]byte(data))
|
_, err := c.Response().Write([]byte(data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Log failure to write and unlock before returning
|
||||||
LogError.Printf("Failed to write message: %v", err)
|
LogError.Printf("Failed to write message: %v", err)
|
||||||
mutex.Unlock()
|
mutex.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush the response if possible
|
||||||
flusher, ok := c.Response().Writer.(http.Flusher)
|
flusher, ok := c.Response().Writer.(http.Flusher)
|
||||||
if ok {
|
if ok {
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
|
@ -129,6 +136,7 @@ func HandleIncomingMessages(c echo.Context, pubsub pubsub.PubSubMessage, client
|
||||||
} else {
|
} else {
|
||||||
LogError.Println("Failed to write: ResponseWriter is nil")
|
LogError.Println("Failed to write: ResponseWriter is nil")
|
||||||
}
|
}
|
||||||
|
// Ensure the mutex is unlocked after processing each message
|
||||||
mutex.Unlock()
|
mutex.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue