Rotational training registration to message-bus (#903)
This commit is contained in:
parent
151aa037bb
commit
a7126cac63
2 changed files with 13 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
|||
Description=rclone
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/rm -f /var/run/rclone/rclone.sock
|
||||
ExecStartPre=/usr/bin/mkdir -p /var/run/rclone && /usr/bin/rm -f /var/run/rclone/rclone.sock
|
||||
ExecStart=/usr/bin/rclone rcd --rc-addr unix:///var/run/rclone/rclone.sock --rc-no-auth --rc-allow-origin "*"
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
|
8
main.go
8
main.go
|
@ -165,15 +165,19 @@ func main() {
|
|||
events = append(events, message_bus.EventType{Name: "casaos:file:recover", SourceID: common.SERVICENAME, PropertyTypeList: []message_bus.PropertyType{}})
|
||||
events = append(events, message_bus.EventType{Name: "casaos:file:operate", SourceID: common.SERVICENAME, PropertyTypeList: []message_bus.PropertyType{}})
|
||||
// register at message bus
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
response, err := service.MyService.MessageBus().RegisterEventTypesWithResponse(context.Background(), events)
|
||||
if err != nil {
|
||||
logger.Error("error when trying to register one or more event types - some event type will not be discoverable", zap.Error(err))
|
||||
}
|
||||
|
||||
if response != nil && response.StatusCode() != http.StatusOK {
|
||||
logger.Error("error when trying to register one or more event types - some event type will not be discoverable", zap.String("status", response.Status()), zap.String("body", string(response.Body)))
|
||||
}
|
||||
if response.StatusCode() == http.StatusOK {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Second * 2)
|
||||
|
|
Loading…
Reference in a new issue