Skip to content

Commit

Permalink
Serve exit fixes & debug logs (#141)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Lombardi <[email protected]>
  • Loading branch information
luke-lombardi and Luke Lombardi authored Apr 16, 2024
1 parent df99692 commit 8b189e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions internal/abstractions/endpoint/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"sort"
"sync"
Expand Down Expand Up @@ -168,6 +169,8 @@ func (rb *RequestBuffer) discoverContainers() {
return
}

log.Printf("<%s> Retrieved container address: %s\n", cs.ContainerId, containerAddress)

inFlight, err := rb.requestsInFlight(cs.ContainerId)
if err != nil {
return
Expand All @@ -179,7 +182,11 @@ func (rb *RequestBuffer) discoverContainers() {
address: containerAddress,
inFlight: inFlight,
}
return
}

log.Printf("<%s> Container not ready\n", cs.ContainerId)

}(containerState)
}

Expand Down
7 changes: 4 additions & 3 deletions sdk/src/beta9/runner/serve.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import atexit
import os
import signal
import subprocess
Expand Down Expand Up @@ -47,6 +46,9 @@ def __init__(self) -> None:
self.restart_event = Event()
self.exit_event = Event()

# Register signal handlers
signal.signal(signal.SIGTERM, self.shutdown)

# Set up the file change event handler & observer
self.event_handler = SyncEventHandler(self.trigger_restart)
self.observer = PollingObserver()
Expand All @@ -56,7 +58,7 @@ def __init__(self) -> None:
def shutdown(self, signum=None, frame=None) -> None:
self.kill_subprocess()
self.observer.stop()
self.observer.join()
self.observer.join(timeout=0.1)
self.exit_event.set()
self.restart_event.set()

Expand Down Expand Up @@ -117,7 +119,6 @@ def _command() -> List[str]:

if __name__ == "__main__":
sg = ServeGateway()
atexit.register(sg.shutdown)

try:
sg.run(command=_command())
Expand Down

0 comments on commit 8b189e0

Please sign in to comment.