47 lines
830 B
Go
47 lines
830 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"goRedisDLM/rpcSupport"
|
|
"goRedisDLM/worker"
|
|
"log"
|
|
_ "net/http/pprof"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
var port = flag.String("port", "", "port")
|
|
var redisHost = flag.String("redis", "", "redis host")
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
if *port == "" || *redisHost == "" {
|
|
log.Println("port err")
|
|
flag.Usage()
|
|
|
|
return
|
|
}
|
|
|
|
/*
|
|
pprof, err := strconv.Atoi(strings.Trim(*port, ":"))
|
|
if err != nil {
|
|
log.Println("pprof port error")
|
|
|
|
return
|
|
}
|
|
|
|
pprofPort := fmt.Sprintf(":%d", pprof+100)
|
|
|
|
go func() {
|
|
log.Println("pprof listen on: ", pprofPort)
|
|
log.Fatal(http.ListenAndServe(pprofPort, nil))
|
|
}()
|
|
*/
|
|
redisClient := redis.NewClient(&redis.Options{
|
|
Addr: *redisHost,
|
|
Password: "",
|
|
})
|
|
|
|
log.Fatal(rpcSupport.RpcServer(*port, &worker.Inventory{Client: redisClient}))
|
|
}
|