set things right

This commit is contained in:
Andre Medeiros 2021-07-08 21:07:01 -04:00
parent 0f70725be5
commit 09c42c379c
2 changed files with 6 additions and 4 deletions

View file

@ -93,7 +93,7 @@ func main() {
s.StartAsync() s.StartAsync()
signals := make(chan os.Signal, 1) signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(signals) defer signal.Stop(signals)
<-signals // wait for signal <-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) { 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() start := time.Now().Unix()
end := start + 1 end := start + 1
@ -126,10 +128,10 @@ func enqueueAccounts(ctx context.Context, logger *logrus.Logger, pool *pgxpool.P
ORDER BY last_checked_at ORDER BY last_checked_at
) )
UPDATE accounts UPDATE accounts
SET last_enqueued_at = $1 SET last_enqueued_at = $3
WHERE accounts.id IN(SELECT id FROM account) WHERE accounts.id IN(SELECT id FROM account)
RETURNING accounts.id` RETURNING accounts.id`
rows, err := tx.Query(ctx, stmt, start, end) rows, err := tx.Query(ctx, stmt, start, end, now)
if err != nil { if err != nil {
return err return err
} }

View file

@ -142,7 +142,7 @@ func main() {
} }
signals := make(chan os.Signal, 1) signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGINT) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(signals) defer signal.Stop(signals)
<-signals // wait for signal <-signals // wait for signal