Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
admpub committed Feb 17, 2024
1 parent 81a2319 commit 1f0ab20
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions application/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func initRunE(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
req.SetFromCLI(true)
ctx.Internal().Set(`validated`, req)
err = setup.Setup(ctx)
if err == nil {
Expand Down
9 changes: 6 additions & 3 deletions application/handler/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,12 @@ func Setup(ctx echo.Context) error {
return err
}

// 启动
log.Info(color.GreenString(`[installer]`), `Start up`)
config.FromCLI().RunStartup()
if !requestData.FromCLI() {
log.Info(color.GreenString(`[installer]`), `Start up`)
config.FromCLI().RunStartup() // 启动
} else {
config.FromCLI().ParseConfig()
}

// 升级
if err := Upgrade(); err != nil && os.ErrNotExist != err {
Expand Down
2 changes: 1 addition & 1 deletion application/registry/settings/config_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ var configDefaults = map[string]map[string]*dbschema.NgingConfig{
Key: `targets`,
Label: `输出`,
Description: ``,
Value: `console`,
Value: `console,file`,
Group: `log`,
Type: `list`,
Sort: 0,
Expand Down
9 changes: 9 additions & 0 deletions application/request/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ type Setup struct {
AdminUser string `validate:"username"`
AdminPass string `validate:"required,min=8,max=64"`
AdminEmail string `validate:"required,email"`
fromCLI bool
}

func (s *Setup) SetFromCLI(fromCLI bool) {
s.fromCLI = fromCLI
}

func (s *Setup) FromCLI() bool {
return s.fromCLI
}

func (s *Setup) AfterValidate(c echo.Context) error {
Expand Down

0 comments on commit 1f0ab20

Please sign in to comment.