Add shutdown to async, rehabilitate http cmd
This commit is contained in:
parent
d49f866ca4
commit
b31d3b907a
@ -5,7 +5,9 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"syscall"
|
||||
|
||||
"git.defalsify.org/vise.git/asm"
|
||||
"git.defalsify.org/vise.git/db"
|
||||
@ -210,6 +212,19 @@ func main() {
|
||||
Writer: os.Stdout,
|
||||
Config: cfg,
|
||||
}
|
||||
|
||||
cint := make(chan os.Signal)
|
||||
cterm := make(chan os.Signal)
|
||||
signal.Notify(cint, os.Interrupt, syscall.SIGINT)
|
||||
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
select {
|
||||
case _ = <-cint:
|
||||
case _ = <-cterm:
|
||||
}
|
||||
sh.Shutdown()
|
||||
}()
|
||||
|
||||
for true {
|
||||
rqs, err = sh.Process(rqs)
|
||||
if err != nil {
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/internal/handlers/ussd"
|
||||
"git.grassecon.net/urdt/ussd/internal/handlers"
|
||||
httpserver "git.grassecon.net/urdt/ussd/internal/http"
|
||||
)
|
||||
|
||||
@ -191,7 +192,8 @@ func main() {
|
||||
|
||||
rp := &httpserver.DefaultRequestParser{}
|
||||
//sh := httpserver.NewSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl.Init)
|
||||
sh := httpserver.NewSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||
bsh := handlers.NewBaseSessionHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||
sh := httpserver.ToSessionHandler(bsh)
|
||||
s := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
||||
Handler: sh,
|
||||
|
@ -38,6 +38,7 @@ type RequestSession struct {
|
||||
|
||||
type engineMaker func(cfg engine.Config, rs resource.Resource, pr *persist.Persister) engine.Engine
|
||||
|
||||
// TODO: seems like can remove this.
|
||||
type RequestParser interface {
|
||||
GetSessionId(rq any) (string, error)
|
||||
GetInput(rq any) ([]byte, error)
|
||||
@ -50,5 +51,5 @@ type RequestHandler interface {
|
||||
Process(rs RequestSession) (RequestSession, error)
|
||||
Output(rs RequestSession) (RequestSession, error)
|
||||
Reset(rs RequestSession) (RequestSession, error)
|
||||
ShutDown()
|
||||
Shutdown()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user