diff options
| author | unwox <me@unwox.com> | 2024-08-23 21:34:11 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-08-23 21:34:11 +0600 |
| commit | c8a5f8a68f28e8d910c648d52125f8d28b400b25 (patch) | |
| tree | 1530bd25e828f5c886ce7eaa37f3789d3708825f /main.go | |
| parent | 308b69f717931f06916847a1c987be87a40e43dc (diff) | |
allow to change number of workers with -n flag
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -9,15 +9,19 @@ import ( "log" "net/http" "os" + "runtime" "strings" "time" ) func main() { - if len(os.Args) != 2 { + wrksNum := flag.Int("n", runtime.NumCPU(), "Number of HTTP-workers to start") + flag.Parse() + + if flag.NArg() != 1 { printUsage() } - luaExe := os.Args[1] + luaExe := flag.Arg(0) mustExist(luaExe) httpClient := &http.Client{} @@ -135,7 +139,7 @@ func main() { module["http"] = httpModule // start workers - for i := 0; i < 1; i++ { + for i := 0; i < *wrksNum; i++ { wrk := NewWorker() wrks = append(wrks, wrk) go func () { |
