rpc on random port, if using local shorthand
This commit is contained in:
parent
21a41cccf5
commit
8a1e56ba1b
13
main.go
13
main.go
|
@ -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 {
|
if startServer && startClient && rán == "" && hev == "" {
|
||||||
if rán == "" {
|
rán = fmt.Sprintf(":%d", rand.Intn(30000)+1000)
|
||||||
rán = ":5555"
|
hev = rán
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if startServer {
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue