File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 4
4
"os"
5
5
"os/signal"
6
6
"syscall"
7
+ "time"
7
8
8
9
"github.com/CortexFoundation/CortexTheseus/log"
9
10
"github.com/CortexFoundation/robot"
@@ -24,11 +25,18 @@ func main() {
24
25
panic (err )
25
26
} else {
26
27
m .SwitchService (robot .SRV_PRINT )
28
+
27
29
if err := m .Start (); err != nil {
28
30
log .Error ("start failed" , "err" , err )
29
31
panic (err )
30
32
}
31
33
defer m .Stop ()
34
+
35
+ go func () {
36
+ time .Sleep (5 * time .Second )
37
+ m .SwitchService (robot .SRV_MODEL )
38
+ }()
39
+
32
40
var c = make (chan os.Signal , 1 )
33
41
signal .Notify (c , os .Interrupt , syscall .SIGTERM )
34
42
<- c
Original file line number Diff line number Diff line change @@ -838,7 +838,10 @@ func (m *Monitor) solve(block *types.Block) error {
838
838
}
839
839
840
840
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
+ }
842
845
return nil
843
846
}
844
847
You can’t perform that action at this time.
0 commit comments