Skip to content

Commit

Permalink
gs
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Apr 6, 2024
1 parent 617a6c0 commit cf92f76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions http_service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
// "os"
// "os/signal"
// "syscall"

"github.com/Brandon-lz/myopcua/http_service/routers"
webhookrouters "github.com/Brandon-lz/myopcua/http_service/routers/webhook_routers"
Expand Down Expand Up @@ -67,12 +67,12 @@ func Start(ctx context.Context) {

// Wait for interrupt signal to gracefully shutdown the server with
// a timeout of 5 seconds.
quit := make(chan os.Signal)
// quit := make(chan os.Signal)
// kill (no param) default send syscanll.SIGTERM
// kill -2 is syscall.SIGINT
// kill -9 is syscall. SIGKILL but can"t be catch, so don't need add it
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
// signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
// <-quit
slog.Info("Shutdown Server ...")

if err := srv.Shutdown(ctx); err != nil {
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"log/slog"

"github.com/Brandon-lz/myopcua/config"
Expand Down Expand Up @@ -33,7 +34,8 @@ func main() {
db.InitDB()
query.SetDefault(db.DB) // init gen model, for decouple with db
globaldata.InitSystemVars()
go opcservices.Start()
go httpservice.Start()
ctx := context.Background()
go opcservices.Start(ctx)
go httpservice.Start(ctx)
select {}
}

0 comments on commit cf92f76

Please sign in to comment.