Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: fix first boot slow in no network env && remove msg register #189

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/robfig/cron/v3"

util_http "github.com/IceWhaleTech/CasaOS-Common/utils/http"
"github.com/IceWhaleTech/CasaOS-Installer/codegen/message_bus"

"github.com/IceWhaleTech/CasaOS-Installer/common"
"github.com/IceWhaleTech/CasaOS-Installer/internal/config"
Expand Down Expand Up @@ -140,7 +139,6 @@ func main() {
}

go registerRouter(listener)
go registerMsg()

// should do before cron job to prevent stop by `installing` status
err = service.InstallerService.PostMigration(sysRoot)
Expand Down Expand Up @@ -215,27 +213,6 @@ func watchOfflineDir(watcher *fsnotify.Watcher) {
}
}

func registerMsg() {
var messageBus *message_bus.ClientWithResponses
var err error
for i := 0; i < 10; i++ {
if messageBus, err = service.MyService.MessageBus(); err != nil {
logger.Error("error when trying to connect to message bus... skipping", zap.Error(err))
continue
}
response, err := messageBus.RegisterEventTypesWithResponse(context.Background(), common.EventTypes)
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))
continue
}
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)))
continue
}
time.Sleep(3 * time.Second)
}
}

func registerRouter(listener net.Listener) {
for i := 0; i < 10; i++ {
// initialize routers and register at gateway
Expand Down
10 changes: 9 additions & 1 deletion service/status_serivce.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ func NewStatusService(implementService UpdaterServiceInterface, sysRoot string)
statusService.status = codegen.Status{
Status: codegen.Idle,
}
statusService.release, _ = implementService.GetRelease(context.Background(), GetReleaseBranch(sysRoot), true)

go func() {
release, err := implementService.GetRelease(context.Background(), GetReleaseBranch(sysRoot), true)
if err != nil {
logger.Error("fail get release", zap.Error(err))
} else {
statusService.release = release
}
}()
return statusService
}

Expand Down
Loading