| | |
| | | import ( |
| | | "analysis/logo" |
| | | "analysis/util" |
| | | "fmt" |
| | | "os/exec" |
| | | "os/signal" |
| | | "runtime/debug" |
| | | "strconv" |
| | | "syscall" |
| | | "time" |
| | | |
| | | "analysis/app/master" |
| | | "analysis/app/slave" |
| | |
| | | "flag" |
| | | |
| | | "os" |
| | | |
| | | "basic.com/valib/gogpu.git" |
| | | // "net/http" |
| | | // _ "net/http/pprof" |
| | | ) |
| | |
| | | ruleIPC string |
| | | |
| | | configPath string |
| | | |
| | | showConsole bool |
| | | ) |
| | | |
| | | const ( |
| | |
| | | ) |
| | | |
| | | func init() { |
| | | flag.StringVar(&role, "role", roleMaster, "run process role master/slave, default single") |
| | | flag.StringVar(&runType, "sdk", util.FeatAll, "run sdk type, face/facedetect/facecompare/yolo,etc.") |
| | | flag.StringVar(&role, "role", roleMaster, "run process role master/slave, default master") |
| | | flag.StringVar(&runType, "sdk", util.FeatAll, "run sdk type, facedetect/yolo,etc.") |
| | | flag.StringVar(&id, "id", util.FakeSdkID, "sdk id as ipc label") |
| | | |
| | | flag.StringVar(&configPath, util.ConfigPath, "", "sdk config file path") |
| | |
| | | flag.BoolVar(&shm, util.SHM, false, "use shm for performance") |
| | | |
| | | flag.IntVar(&gpu, util.GPU, -1, "gpu index") |
| | | |
| | | flag.BoolVar(&showConsole, "log-console", false, "log show console, only for debug") |
| | | |
| | | // 指定获取配置信息从sqlite,有最高优先级, master使用 |
| | | flag.StringVar(&util.FSI.IP, util.FetchSrvIP, util.FSI.IP, "fetch server ip, like camera info") |
| | |
| | | logo.Config(file, 500, 3, 30) |
| | | logo.Infoln("START LOGGER FILE: ", file) |
| | | } |
| | | if showConsole { |
| | | logo.ShowConsole() |
| | | } |
| | | logo.ShowConsole() |
| | | } |
| | | |
| | | func setParamters() { |
| | |
| | | |
| | | func main() { |
| | | |
| | | indices := gogpu.RankGPU() |
| | | if len(indices) == 0 { |
| | | logo.Errorln("there is no gpu for valid") |
| | | return |
| | | } |
| | | |
| | | util.InitConfig() |
| | | |
| | | flag.Parse() |
| | |
| | | |
| | | ret := false |
| | | if role == roleMaster { |
| | | defer dump(util.LogFile + "_dump_" + time.Now().Format("20060102150405")) |
| | | setParamters() |
| | | ret = master.Run(ctx, configPath, "./libcomm.so") |
| | | ret = master.Run(ctx, "./libcomm.so", configPath) |
| | | |
| | | } else if role == roleSlave { |
| | | ret = slave.Run(ctx, configPath, runType, id, gpu, shm) |
| | | } else if role == "test" { |
| | | ret = slave.TwoPluginConflict("./libcomm.so", "./zconf/Yolo.json") |
| | | } |
| | | |
| | | if ret { |
| | | c := make(chan os.Signal, 1) |
| | | signal.Notify(c, os.Interrupt, os.Kill) |
| | | signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGTERM) |
| | | <-c |
| | | } |
| | | |
| | |
| | | // viper.AddConfigPath("./") |
| | | |
| | | // envString := "" |
| | | |
| | | func dump(dumpFile string) { |
| | | dumpErr := recover() |
| | | if dumpErr == nil { |
| | | return |
| | | } |
| | | f, err := os.Create(dumpFile) |
| | | if err != nil { |
| | | return |
| | | } |
| | | f.WriteString(fmt.Sprintf("panic:\r\n%v", dumpErr)) |
| | | f.WriteString("\r\n\nstack:\r\n") |
| | | f.WriteString(string(debug.Stack())) |
| | | f.Close() |
| | | |
| | | ////////////////////////////////////////////// |
| | | // restart master |
| | | |
| | | cmd := exec.Command(os.Args[0], os.Args[1:]...) |
| | | cmd.Stdout = os.Stdout |
| | | cmd.Stderr = os.Stderr |
| | | cmd.Start() |
| | | } |