cmd/pkgserver: move API implementation to package
For moving into cmd/mbf. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -10,9 +10,11 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"hakurei.app/cmd/pkgserver/internal/ui"
|
||||
"hakurei.app/command"
|
||||
"hakurei.app/internal/rosa"
|
||||
|
||||
"hakurei.app/cmd/pkgserver/internal/pkgserver"
|
||||
"hakurei.app/cmd/pkgserver/internal/pkgserver/ui"
|
||||
)
|
||||
|
||||
const shutdownTimeout = 15 * time.Second
|
||||
@@ -48,26 +50,11 @@ func main() {
|
||||
return errors.New("pkgserver requires 1 argument")
|
||||
}
|
||||
|
||||
var index packageIndex
|
||||
index.search = make(searchCache)
|
||||
if err := index.populate(report); err != nil {
|
||||
return err
|
||||
}
|
||||
ticker := time.NewTicker(1 * time.Minute)
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
ticker.Stop()
|
||||
return
|
||||
case <-ticker.C:
|
||||
index.search.clean()
|
||||
}
|
||||
}
|
||||
}()
|
||||
var mux http.ServeMux
|
||||
ui.Register(&mux)
|
||||
index.registerAPI(&mux)
|
||||
if err := pkgserver.Register(ctx, &mux, report); err != nil {
|
||||
return err
|
||||
}
|
||||
server := http.Server{
|
||||
Addr: flagAddr,
|
||||
Handler: &mux,
|
||||
|
||||
Reference in New Issue
Block a user