From 09c42c379c63b1e160134dcc370532ef4796ae1a Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Thu, 8 Jul 2021 21:07:01 -0400 Subject: [PATCH] set things right --- cmd/apollo-scheduler/main.go | 8 +++++--- cmd/apollo-worker-notifications/main.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/apollo-scheduler/main.go b/cmd/apollo-scheduler/main.go index e9475e8..97d5305 100644 --- a/cmd/apollo-scheduler/main.go +++ b/cmd/apollo-scheduler/main.go @@ -93,7 +93,7 @@ func main() { s.StartAsync() signals := make(chan os.Signal, 1) - signal.Notify(signals, syscall.SIGINT) + signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) defer signal.Stop(signals) <-signals // wait for signal @@ -107,6 +107,8 @@ func main() { } func enqueueAccounts(ctx context.Context, logger *logrus.Logger, pool *pgxpool.Pool, redisConn *redis.Client, queue rmq.Queue) { + now := float64(time.Now().UnixNano()/int64(time.Millisecond)) / 1000 + start := time.Now().Unix() end := start + 1 @@ -126,10 +128,10 @@ func enqueueAccounts(ctx context.Context, logger *logrus.Logger, pool *pgxpool.P ORDER BY last_checked_at ) UPDATE accounts - SET last_enqueued_at = $1 + SET last_enqueued_at = $3 WHERE accounts.id IN(SELECT id FROM account) RETURNING accounts.id` - rows, err := tx.Query(ctx, stmt, start, end) + rows, err := tx.Query(ctx, stmt, start, end, now) if err != nil { return err } diff --git a/cmd/apollo-worker-notifications/main.go b/cmd/apollo-worker-notifications/main.go index 1c6e6b8..9658ff9 100644 --- a/cmd/apollo-worker-notifications/main.go +++ b/cmd/apollo-worker-notifications/main.go @@ -142,7 +142,7 @@ func main() { } signals := make(chan os.Signal, 1) - signal.Notify(signals, syscall.SIGINT) + signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) defer signal.Stop(signals) <-signals // wait for signal