You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
okapidemo/his/main.go

45 lines
687 B

3 years ago
package main
import (
"context"
"log"
"os"
"os/signal"
"sync"
)
2 years ago
var localAddr = "0.0.0.0:8084"
var externalAddr = "https://localhost:8084"
3 years ago
func main() {
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
wg := &sync.WaitGroup{}
2 years ago
if os.Getenv("LOCAL_ADDR") != "" {
localAddr = os.Getenv("LOCAL_ADDR")
}
3 years ago
2 years ago
if os.Getenv("EXT_ADDR") != "" {
externalAddr = os.Getenv("EXT_ADDR")
}
3 years ago
2 years ago
srv := NewServer(localAddr)
3 years ago
srv.LoadData("./data/data.db")
go func() {
wg.Add(1)
srv.ListenAndServe()
}()
<-stop
go func() {
log.Println("Shutdown server...")
srv.Shutdown(context.Background())
wg.Done()
log.Println("Server.shutdown...")
}()
wg.Wait()
}