rpc on random port, if using local shorthand

This commit is contained in:
Norwin Roosen 2020-12-31 12:51:37 +01:00
parent 21a41cccf5
commit 8a1e56ba1b
No known key found for this signature in database
GPG Key ID: 24BC059DE24C43A3
1 changed files with 7 additions and 6 deletions

13
main.go
View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"image" "image"
"log" "log"
"math/rand"
"os" "os"
"os/signal" "os/signal"
"runtime/pprof" "runtime/pprof"
@ -30,6 +31,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
rand.Seed(time.Now().UnixNano())
task := runWithExitHandler(taskFromFlags) task := runWithExitHandler(taskFromFlags)
if *cpuprofile != "" { if *cpuprofile != "" {
runWithProfiler(*cpuprofile, task) runWithProfiler(*cpuprofile, task)
@ -52,10 +54,12 @@ func taskFromFlags(stop chan bool, wg *sync.WaitGroup) {
os.Exit(1) os.Exit(1)
} }
if startServer && startClient && rán == "" && hev == "" {
rán = fmt.Sprintf(":%d", rand.Intn(30000)+1000)
hev = rán
}
if startServer { if startServer {
if rán == "" {
rán = ":5555"
}
r := rpc.SummonRán(rán, stop, wg) r := rpc.SummonRán(rán, stop, wg)
var img *image.NRGBA var img *image.NRGBA
@ -71,9 +75,6 @@ func taskFromFlags(stop chan bool, wg *sync.WaitGroup) {
} }
if startClient { if startClient {
if hev == "" {
hev = ":5555"
}
rpc.ConnectHevring(hev, stop, wg) rpc.ConnectHevring(hev, stop, wg)
} }