mirror of
https://github.com/aljazceru/crawler_v2.git
synced 2025-12-18 07:54:25 +01:00
created utils file to better organize code
This commit is contained in:
@@ -4,10 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/vertex-lab/crawler_v2/pkg/graph"
|
||||
@@ -214,13 +211,3 @@ func Promote(db redb.RedisDB, node graph.ID) error {
|
||||
|
||||
return db.Promote(ctx, node)
|
||||
}
|
||||
|
||||
// HandleSignals listens for OS signals and triggers context cancellation.
|
||||
func HandleSignals(cancel context.CancelFunc) {
|
||||
signals := make(chan os.Signal, 1)
|
||||
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-signals
|
||||
|
||||
log.Println("signal received. shutting down...")
|
||||
cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user