Skip to content

Commit

Permalink
chore: prepare v2.0.0-beta.37
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Oct 26, 2024
1 parent 6dc6092 commit c8c0446
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 54 deletions.
4 changes: 2 additions & 2 deletions api/system/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package system

import (
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/kernal"
"github.com/0xJacky/Nginx-UI/internal/kernel"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/query"
"github.com/0xJacky/Nginx-UI/settings"
Expand Down Expand Up @@ -58,7 +58,7 @@ func InstallNginxUI(c *gin.Context) {
}

// Init model
kernal.InitDatabase()
kernel.InitDatabase()

pwd, _ := bcrypt.GenerateFromPassword([]byte(json.Password), bcrypt.DefaultCost)

Expand Down
2 changes: 0 additions & 2 deletions app/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ declare module 'vue' {
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
APopover: typeof import('ant-design-vue/es')['Popover']
AProgress: typeof import('ant-design-vue/es')['Progress']
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
AResult: typeof import('ant-design-vue/es')['Result']
ARow: typeof import('ant-design-vue/es')['Row']
ASelect: typeof import('ant-design-vue/es')['Select']
Expand Down
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nginx-ui-app-next",
"type": "module",
"version": "2.0.0-beta.36",
"version": "2.0.0-beta.37",
"packageManager": "[email protected]",
"scripts": {
"dev": "vite --host",
Expand Down Expand Up @@ -54,10 +54,10 @@
"@antfu/eslint-config": "^3.8.0",
"@iconify-json/fa": "1.1.5",
"@iconify-json/tabler": "1.1.95",
"@iconify/tools": "3.0.5",
"@iconify/tools": "^4.0.7",
"@iconify/types": "^2.0.0",
"@iconify/utils": "^2.1.33",
"@iconify/vue": "4.1.1",
"@iconify/vue": "^4.1.2",
"@simplewebauthn/types": "^11.0.0",
"@types/lodash": "^4.17.12",
"@types/nprogress": "^0.2.3",
Expand Down
39 changes: 14 additions & 25 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.0.0-beta.36","build_id":1,"total_build":365}
{"version":"2.0.0-beta.37","build_id":1,"total_build":366}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/spf13/cast v1.7.0
github.com/stretchr/testify v1.9.0
github.com/tufanbarisyildirim/gonginx v0.0.0-20241013191809-e73b7dd454e8
github.com/uozi-tech/cosy v1.9.8
github.com/uozi-tech/cosy v1.9.9
github.com/uozi-tech/cosy-driver-sqlite v0.2.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.28.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRY
cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM=
cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I=
cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY=
cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE=
cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4=
cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw=
cloud.google.com/go/accessapproval v1.6.0/go.mod h1:R0EiYnwV5fsRFiKZkPHr6mwyk2wxUJ30nL4j2pcFY2E=
Expand Down Expand Up @@ -760,6 +761,7 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down Expand Up @@ -1674,6 +1676,8 @@ github.com/uozi-tech/cosy v1.9.4 h1:oG5TbrS8XUpZnQ++9gxI5if0++uJ7h9nMPZPNeDgly0=
github.com/uozi-tech/cosy v1.9.4/go.mod h1:aQI/OU3EVF125K5ECgSg3+CTfG4cp5XOkr++DEP/Fas=
github.com/uozi-tech/cosy v1.9.8 h1:c3xKdG9Pa3PqRVjxr2teDjAGe0PNcFs1X5/fCiROkbY=
github.com/uozi-tech/cosy v1.9.8/go.mod h1:aQI/OU3EVF125K5ECgSg3+CTfG4cp5XOkr++DEP/Fas=
github.com/uozi-tech/cosy v1.9.9 h1:hA8R9Q0JuykDG1G6WO62cgi2oxJyONrjdg525Xu7AG0=
github.com/uozi-tech/cosy v1.9.9/go.mod h1:aQI/OU3EVF125K5ECgSg3+CTfG4cp5XOkr++DEP/Fas=
github.com/uozi-tech/cosy-driver-mysql v0.2.2 h1:22S/XNIvuaKGqxQPsYPXN8TZ8hHjCQdcJKVQ83Vzxoo=
github.com/uozi-tech/cosy-driver-mysql v0.2.2/go.mod h1:EZnRIbSj1V5U0gEeTobrXai/d1SV11lkl4zP9NFEmyE=
github.com/uozi-tech/cosy-driver-postgres v0.2.1 h1:OICakGuT+omva6QOJCxTJ5Lfr7CGXLmk/zD+aS51Z2o=
Expand Down
Binary file removed img.png
Binary file not shown.
3 changes: 1 addition & 2 deletions internal/kernal/boot.go → internal/kernel/boot.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kernal
package kernel

import (
"crypto/rand"
Expand Down Expand Up @@ -27,7 +27,6 @@ func Boot() {
defer recovery()

async := []func(){
settings.Init,
InitJsExtensionType,
InitDatabase,
InitNodeSecret,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kernal
package kernel

import (
"github.com/0xJacky/Nginx-UI/query"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kernal
package kernel

import (
"github.com/0xJacky/Nginx-UI/model"
Expand Down
44 changes: 33 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,57 @@ package main
import (
"flag"
"fmt"
"github.com/0xJacky/Nginx-UI/internal/kernal"
"github.com/0xJacky/Nginx-UI/internal/nginx"
"github.com/0xJacky/Nginx-UI/internal/kernel"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/router"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/jpillora/overseer"
"github.com/pkg/errors"
"github.com/uozi-tech/cosy"
cKernel "github.com/uozi-tech/cosy/kernel"
"github.com/uozi-tech/cosy/logger"
cRouter "github.com/uozi-tech/cosy/router"
cSettings "github.com/uozi-tech/cosy/settings"
"net/http"
"time"
)

func Program(confPath string) func(state overseer.State) {
return func(state overseer.State) {
defer logger.Sync()

defer logger.Info("Server exited")
cosy.RegisterModels(model.GenerateAllModel()...)

cosy.RegisterAsyncFunc(kernal.Boot, router.InitRouter)
cosy.RegisterAsyncFunc(kernel.Boot, router.InitRouter)

// Initialize settings package
settings.Init(confPath)

if state.Listener != nil {
cosy.SetListener(state.Listener)
// Set gin mode
gin.SetMode(cSettings.ServerSettings.RunMode)

cosy.Boot(confPath)
// Initialize logger package
logger.Init(cSettings.ServerSettings.RunMode)
defer logger.Sync()

logger.Infof("Nginx configuration directory: %s", nginx.GetConfPath())
if state.Listener == nil {
return
}
// Gin router initialization
cRouter.Init()

// Kernel boot
cKernel.Boot()

addr := fmt.Sprintf("%s:%d", cSettings.ServerSettings.Host, cSettings.ServerSettings.Port)
srv := &http.Server{
Addr: addr,
Handler: cRouter.GetEngine(),
}
if err := srv.Serve(state.Listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Fatalf("listen: %s\n", err)
}
logger.Info("Server exited")
}
}

Expand All @@ -39,8 +62,7 @@ func main() {
flag.StringVar(&confPath, "config", "app.ini", "Specify the configuration file")
flag.Parse()

settings.Migrate(confPath)
cSettings.Init(confPath)
settings.Init(confPath)

overseer.Run(overseer.Config{
Program: Program(confPath),
Expand Down
6 changes: 3 additions & 3 deletions settings/server_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func mergeStructs(src, dst interface{}) {
return
}

func Migrate(confPath string) {
func migrate(confPath string) {
logger.Init("debug")
Conf, err := ini.LoadSources(ini.LoadOptions{
Loose: true,
Expand Down Expand Up @@ -160,7 +160,7 @@ func Migrate(confPath string) {
for name, ptr := range migrated.Iterator() {
err = Conf.Section(name).MapTo(ptr)
if err != nil {
logger.Error("Migrate.MapTo %s err: %v", name, err)
logger.Error("migrate.MapTo %s err: %v", name, err)
}
}

Expand All @@ -187,7 +187,7 @@ func Migrate(confPath string) {
for section, ptr := range migrated.Iterator() {
err = Conf.Section(section).ReflectFrom(ptr)
if err != nil {
logger.Fatalf("Migrate.ReflectFrom %s err: %v", section, err)
logger.Fatalf("migrate.ReflectFrom %s err: %v", section, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion settings/server_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ RPOrigins = http://localhost:3002,http://127.0.0.1:3002`
t.Fatalf("Failed to write config to file: %v", err)
}

Migrate(confName)
migrate(confName)
}
11 changes: 10 additions & 1 deletion settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ func init() {
settings.WithoutSonyflake()
}

func Init() {
func Init(confPath string) {
migrate(confPath)

settings.Init(confPath)

// Set Default Port
if settings.ServerSettings.Port == 0 {
settings.ServerSettings.Port = 9000
}

for prefix, ptr := range envPrefixMap {
parseEnv(ptr, prefix+"_")
}
Expand Down

0 comments on commit c8c0446

Please sign in to comment.