open 1 conn at a time
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.bel.blue/bel/with"
|
||||
@@ -30,7 +31,11 @@ func run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
for i := 0; i < *p-1; i++ {
|
||||
func() {
|
||||
connected := &sync.WaitGroup{}
|
||||
connected.Add(1)
|
||||
go with.PSQL(ctx, *c, func(pg *sql.DB) error {
|
||||
connected.Done()
|
||||
with.GoEvery(ctx, *d, func() {
|
||||
if _, err := pg.ExecContext(ctx, `SELECT 1`); err != nil {
|
||||
log.Println("!", err)
|
||||
@@ -38,6 +43,8 @@ func run(ctx context.Context) error {
|
||||
})
|
||||
return ctx.Err()
|
||||
})
|
||||
connected.Wait()
|
||||
}()
|
||||
}
|
||||
|
||||
return with.PSQL(ctx, *c, func(pg *sql.DB) error {
|
||||
|
||||
Reference in New Issue
Block a user