Archiver API server is not shut down during service stop
- Dominant language
- Go
- Stars
- 126
- Forks
- 87
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
The archiver service starts an HTTP API server, but it does not appear to store or shut down that server during [Stop()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:60:0-80:1).
## What I found
In [archiver/service/service.go](cci:7://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/archiver/service/service.go:0:0-0:0), [Start()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:36:0-58:1) starts the Archiver API server:
`httputil.StartHTTPServer(a.cfg.ListenAddr, a.api.router)`
However, the returned server is only stored in a local variable and is not assigned to the [ArchiverService](cci:2://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/archiver/service/service.go:27:0-35:1) struct.
The [Stop()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:60:0-80:1) method shuts down the metrics server and the archiver, but it does not shut down the Archiver API server.
By contrast, the standalone API service in [api/service/service.go](cci:7://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:0:0-0:0) stores the API server in `apiServer` and calls `Shutdown(ctx)` during [Stop()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:60:0-80:1).
## Expected behavior
The archiver service should keep a reference to the API HTTP server and shut it down during [Stop()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:60:0-80:1), similar to the standalone API service.
## Suggested fix
Add an `apiServer *httputil.HTTPServer` field to [ArchiverService](cci:2://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/archiver/service/service.go:27:0-35:1), assign it in [Start()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:36:0-58:1), and call `Shutdown(ctx)` during [Stop()](cci:1://file:///C:/Users/Zeki/CascadeProjects/blob-archiver-research/api/service/service.go:60:0-80:1).
## Impact
The Archiver API server may continue running after the service is stopped, which can lead to port conflicts, leaked goroutines/sockets, and incomplete graceful shutdown behavior.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with archiver/service/service.go and trace ArchiverService.Start() and Stop(). Compare the API server lifecycle with api/service/service.go, especially how its server is retained and shut down. Done means stopping the archiver also terminates its API listener and avoids leaving the port or related resources active.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100