Skip to content

Commit 17fe4f9

Browse files
authored
Merge pull request #4 from CortexFoundation/dev
srv switch
2 parents 21ce0e3 + c48dcaa commit 17fe4f9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cmd/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"os"
55
"os/signal"
66
"syscall"
7+
"time"
78

89
"github.com/CortexFoundation/CortexTheseus/log"
910
"github.com/CortexFoundation/robot"
@@ -24,11 +25,18 @@ func main() {
2425
panic(err)
2526
} else {
2627
m.SwitchService(robot.SRV_PRINT)
28+
2729
if err := m.Start(); err != nil {
2830
log.Error("start failed", "err", err)
2931
panic(err)
3032
}
3133
defer m.Stop()
34+
35+
go func() {
36+
time.Sleep(5 * time.Second)
37+
m.SwitchService(robot.SRV_MODEL)
38+
}()
39+
3240
var c = make(chan os.Signal, 1)
3341
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
3442
<-c

monitor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,10 @@ func (m *Monitor) solve(block *types.Block) error {
838838
}
839839

840840
func (m *Monitor) SwitchService(srv int) error {
841-
m.srv.Store(int32(srv))
841+
if m.srv.Load() != int32(srv) {
842+
m.srv.Store(int32(srv))
843+
log.Info("Service switch", "srv", m.srv.Load())
844+
}
842845
return nil
843846
}
844847

0 commit comments

Comments
 (0)