Skip to content

Commit 6c62725

Browse files
committed
refactor: user init and update boot sequence #1203
1 parent edb8a8a commit 6c62725

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

internal/kernel/boot.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,25 @@ func Boot(ctx context.Context) {
6767

6868
func InitAfterDatabase(ctx context.Context) {
6969
syncs := []func(ctx context.Context){
70+
InitUser,
7071
registerPredefinedUser,
72+
cluster.RegisterPredefinedNodes,
73+
RegisterAcmeUser,
74+
}
75+
76+
for _, v := range syncs {
77+
v(ctx)
78+
}
79+
80+
asyncs := []func(ctx context.Context){
7181
cert.InitRegister,
7282
cron.InitCronJobs,
73-
cluster.RegisterPredefinedNodes,
7483
analytic.RetrieveNodesStatus,
7584
passkey.Init,
76-
RegisterAcmeUser,
7785
mcp.Init,
7886
}
7987

80-
for _, v := range syncs {
88+
for _, v := range asyncs {
8189
go v(ctx)
8290
}
8391
}

internal/kernel/init_user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"github.com/uozi-tech/cosy"
88
)
99

10-
func InitUser() {
11-
db := cosy.UseDB(context.Background())
10+
func InitUser(ctx context.Context) {
11+
db := cosy.UseDB(ctx)
1212
user := &model.User{}
1313
db.Unscoped().Where("id = ?", 1).Find(user)
1414

@@ -20,7 +20,7 @@ func InitUser() {
2020
},
2121
Name: "admin",
2222
})
23-
return
23+
return
2424
}
2525

2626
// if user is found, check if the user is deleted

0 commit comments

Comments
 (0)