From a8a526303a910433b0da2202f87abf640e367a4c Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期四, 12 十二月 2019 10:46:57 +0800
Subject: [PATCH] bug fixed
---
/dev/null | 36 ------------------
proc/master.go | 3 +
main.go | 16 +++++---
proc/single.go | 64 ++++++++++++++++++++++++--------
4 files changed, 60 insertions(+), 59 deletions(-)
diff --git a/main.go b/main.go
index 1d8d5c1..752aef4 100644
--- a/main.go
+++ b/main.go
@@ -15,6 +15,7 @@
"golang.org/x/sys/unix"
"analysis/gosdk"
+
"basic.com/valib/gogpu.git"
// "net/http"
// _ "net/http/pprof"
@@ -143,18 +144,21 @@
logo.Infoln(os.Args)
ctx, cancel := context.WithCancel(context.Background())
+ ret := false
if role == single {
- proc.SingleRole(ctx, runType, id, gpu, shm)
+ ret = proc.SingleRole(ctx, runType, id, gpu, shm)
} else if role == master {
setParamters()
- proc.MasterRole(ctx)
+ ret = proc.MasterRole(ctx)
} else if role == slave {
- proc.SingleRole(ctx, runType, id, gpu, shm)
+ ret = proc.SingleRole(ctx, runType, id, gpu, shm)
}
- c := make(chan os.Signal, 1)
- signal.Notify(c, os.Interrupt, os.Kill, unix.SIGTERM)
- <-c
+ if ret {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, os.Kill, unix.SIGTERM)
+ <-c
+ }
cancel()
diff --git a/proc/master.go b/proc/master.go
index ddc9d1e..7c69c0a 100644
--- a/proc/master.go
+++ b/proc/master.go
@@ -13,7 +13,7 @@
}
// MasterRole master
-func MasterRole(ctx context.Context) {
+func MasterRole(ctx context.Context) bool {
reaper(ctx)
util.InitDBAPI()
@@ -35,4 +35,5 @@
}
logo.Infof("START %d PROC %d SDK %s ID %s\n", k, pid, v.IpcId, v.SdkType)
}
+ return true
}
diff --git a/proc/single.go b/proc/single.go
index bb2c730..6262a28 100644
--- a/proc/single.go
+++ b/proc/single.go
@@ -5,25 +5,55 @@
"analysis/util"
"analysis/work"
"context"
+ "strings"
)
-// SingleRole 鍗曡繘绋�
-func SingleRole(ctx context.Context, typ string, ipcID string, gpu int, shm bool) {
- util.InitDBAPI()
-
- if typ == util.FeatAll { // run all proc per proc
-
- allProc(ctx, gpu, shm)
- } else if typ == util.FeatFace || typ == util.FeatYolo { // run all face sdk
-
- sdkProc(ctx, typ, gpu, shm)
- } else { // run one sdk per proc, typ is facedetect/yolodetect/facecompare etc. id is ipc
- slaveProc(ctx, typ, ipcID, gpu, shm)
+func slaveProc(ctx context.Context, typ string, id string, gpu int, shm bool) bool {
+ name, ok := prepare(typ, gpu)
+ if !ok {
+ logo.Errorln("SLAVEPROC ERROR: ", name)
+ return false
}
+ if id != util.FakeSdkID {
+ build(name, id, shm)
+ runAll(ctx)
+ } else {
+
+ util.InitDBAPI()
+
+ sdks := util.SDKInfo()
+ // 棣栧厛杩愯yolo
+ for k, v := range sdks {
+ if strings.EqualFold(typ, v.SdkType) {
+ build(v.SdkType, v.IpcId, shm)
+ logo.Infof("SINGLE PROC ID %s TYPE %s\n", k, v.IpcId, v.SdkType)
+ }
+ }
+
+ runAll(ctx)
+ }
+ return true
}
-func sdkProc(ctx context.Context, typ string, gpu int, shm bool) {
+// SingleRole 鍗曡繘绋�
+func SingleRole(ctx context.Context, typ string, ipcID string, gpu int, shm bool) bool {
+ util.InitDBAPI()
+
+ ret := false
+ if typ == util.FeatAll { // run all proc per proc
+
+ ret = allProc(ctx, gpu, shm)
+ } else if typ == util.FeatFace || typ == util.FeatYolo { // run all face sdk
+
+ ret = sdkProc(ctx, typ, gpu, shm)
+ } else { // run one sdk per proc, typ is facedetect/yolodetect/facecompare etc. id is ipc
+ ret = slaveProc(ctx, typ, ipcID, gpu, shm)
+ }
+ return ret
+}
+
+func sdkProc(ctx context.Context, typ string, gpu int, shm bool) bool {
if typ != util.FeatYolo && typ != util.FeatFace {
logo.Errorf("NO THIS SDK PROC SDKPROC : ", typ)
}
@@ -43,7 +73,7 @@
for k, v := range res {
if !v {
logo.Errorln(k, " type proc failed to init")
- return
+ return false
}
}
@@ -59,9 +89,10 @@
}
runAll(ctx)
+ return true
}
-func allProc(ctx context.Context, gpu int, shm bool) {
+func allProc(ctx context.Context, gpu int, shm bool) bool {
var res []bool
for _, v := range work.SDK {
@@ -72,7 +103,7 @@
for k, v := range res {
if !v {
logo.Errorln(k, " ALL PROC FAILED TO INIT")
- return
+ return false
}
}
@@ -94,4 +125,5 @@
}
runAll(ctx)
+ return true
}
diff --git a/proc/slave.go b/proc/slave.go
deleted file mode 100644
index e7c41bd..0000000
--- a/proc/slave.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package proc
-
-import (
- "analysis/logo"
- "analysis/util"
- "context"
- "strings"
-)
-
-func slaveProc(ctx context.Context, typ string, id string, gpu int, shm bool) {
- name, ok := prepare(typ, gpu)
- if !ok {
- logo.Errorln("SLAVEPROC ERROR: ", name)
- return
- }
-
- if id != util.FakeSdkID {
- build(name, id, shm)
- runAll(ctx)
- } else {
-
- util.InitDBAPI()
-
- sdks := util.SDKInfo()
- // 棣栧厛杩愯yolo
- for k, v := range sdks {
- if strings.EqualFold(typ, v.SdkType) {
- build(v.SdkType, v.IpcId, shm)
- logo.Infof("SINGLE PROC ID %s TYPE %s\n", k, v.IpcId, v.SdkType)
- }
- }
-
- runAll(ctx)
- }
-
-}
--
Gitblit v1.8.0