-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (41 loc) · 1.46 KB
/
main.go
File metadata and controls
54 lines (41 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"./perd"
"flag"
)
var httpListen = flag.String("listen", ":8080", "HTTP server bind to address & port. Ex: localhost:80 or :80")
var rubyWorkers = flag.Int64("ruby-workers", 1, "Count of ruby workers.")
var nodejsWorkers = flag.Int64("nodejs-workers", 1, "Count of nodejs workers.")
var golangWorkers = flag.Int64("golang-workers", 1, "Count of golang workers.")
var pythonWorkers = flag.Int64("python-workers", 1, "Count of python workers.")
var cWorkers = flag.Int64("c-workers", 1, "Count of C workers.")
var cppWorkers = flag.Int64("cpp-workers", 1, "Count of C++ workers.")
var phpWorkers = flag.Int64("php-workers", 1, "Count of PHP workers.")
var timeout = flag.Int64("timeout", 30, "Max execution time.")
var separate = flag.Bool("separate", false, "Separate workers by languages.")
var workers = flag.Int64("workers", 1, "Count of workers for non separated workers.")
func main() {
flag.Parse()
var server perd.Server
if *separate {
server = separatedServer()
} else {
server = nonSeparatedServer()
}
server.Run()
}
func nonSeparatedServer() perd.Server {
return perd.NewUniversalServer(*httpListen, *workers, *timeout)
}
func separatedServer() perd.Server {
workersMap := map[string]int64{
"ruby": *rubyWorkers,
"nodejs": *nodejsWorkers,
"golang": *golangWorkers,
"python": *pythonWorkers,
"c": *cWorkers,
"cpp": *cppWorkers,
"php": *phpWorkers,
}
return perd.NewServer(*httpListen, workersMap, *timeout)
}