diff options
| author | unwox <me@unwox.com> | 2024-09-27 15:32:48 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-09-27 15:32:48 +0600 |
| commit | 22dd9e85fcd899a4521ca2358e2310fc04998cbf (patch) | |
| tree | 84ddd885487380542c49d6c9acfdb5ed2b76dee0 | |
| parent | 51872975d12c358b2ff0af9f78cda3c9490e486d (diff) | |
wait till all workers start before starting repl
| -rw-r--r-- | main.go | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -13,6 +13,7 @@ import ( "runtime" "runtime/cgo" "strings" + "sync" "time" _ "github.com/mattn/go-sqlite3" @@ -341,6 +342,8 @@ func main() { module["http"] = httpModule module["db"] = dbModule + wg := sync.WaitGroup{} + wg.Add(*wrksNum) // start workers for i := 0; i < *wrksNum; i++ { wrk := NewWorker() @@ -352,10 +355,12 @@ func main() { } wrks = append(wrks, wrk) log.Printf("worker %d started\n", i) + wg.Add(-1) wrk.Listen(msgs) }() defer wrk.Stop() } + wg.Wait() // listen for evals from stdio go func () { |
