Skip to content
Closed
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
49 changes: 49 additions & 0 deletions .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker Image CI

on:
push:
tags:
- 'v*'
branches: []

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64

- name: Set up docker buildx
uses: docker/setup-buildx-action@v2

- name: Read version from file
run: |
VERSION=$(cut -d '|' -f 2 ./service/assets/version)
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Convert repository name to lowercase
run: |
echo "REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ env.REPO_LOWER }}:latest
ghcr.io/${{ env.REPO_LOWER }}:${{ env.VERSION }}
39 changes: 0 additions & 39 deletions .github/workflows/docker-build-push-beta.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/docker-build-push.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ service/lang
service/database
service/web
service/uploads
service/plugins
service/plugins
service/database.db
service/sun-panel

17 changes: 1 addition & 16 deletions service/assets/conf.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@
http_port=3002
# Database driver [mysql/sqlite(Default)]
database_drive=sqlite
# Cache driver [redis/memory(Default)]
cache_drive=memory
# Queue driver [redis/memory(Default)]
queue_drive=memory
# File cache path (Please start with the current path './')
# Warning: The files that have been uploaded after the modification cannot be accessed
source_path=./uploads
# File cache path.
source_temp_path=./runtime/temp

# ======================
# Mysql database driver
Expand All @@ -31,13 +25,4 @@ wait_timeout=100
# sqlite database driver
# ======================
[sqlite]
file_path=./database/database.db

# ======================
# redis database driver
# ======================
[redis]
address=127.0.0.1:6379
password=
prefix=sun_panel:
db=0
file_path=./database/database.db
2 changes: 1 addition & 1 deletion service/assets/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10|1.3.0
10|1.3.1
26 changes: 1 addition & 25 deletions service/global/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,13 @@ package global

import (
"sun-panel/lib/cache"
"sun-panel/structs"
"time"
)

// 缓存驱动
const (
CACHE_DRIVE_REDIS = "redis"
CACHE_DRIVE_MEMORY = "memory"
)

// 创建一个缓存区
// | defaultExpiration:默认过期时长
// | cleanupInterval:清理过期的key间隔 0.不清理
// | name:缓存名称
func NewCache[T any](defaultExpiration time.Duration, cleanupInterval time.Duration, name string) cache.Cacher[T] {
drive := Config.GetValueString("base", "cache_drive")
if drive == "" {
drive = CACHE_DRIVE_MEMORY
}
var cacher cache.Cacher[T]
Logger.Debugln("缓存驱动:", drive)
switch drive {
case CACHE_DRIVE_MEMORY:
cacher = cache.NewGoCache[T](defaultExpiration, cleanupInterval)
case CACHE_DRIVE_REDIS:
redisConfig := structs.IniConfigRedis{}
if err := Config.GetSection("redis", &redisConfig); err != nil {
redisConfig.Prefix = ""
}
cacher = cache.NewRedisCache[T](RedisDb, redisConfig.Prefix+name, defaultExpiration, cleanupInterval)
}

return cacher
return cache.NewGoCache[T](defaultExpiration, cleanupInterval)
}
2 changes: 0 additions & 2 deletions service/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sun-panel/lib/language"
"sun-panel/models"

redis "github.com/redis/go-redis/v9"
"go.uber.org/zap"
"gorm.io/gorm"
)
Expand All @@ -33,7 +32,6 @@ var (
VerifyCodeCachePool cache.Cacher[string]
Config *iniConfig.IniConfig
Db *gorm.DB
RedisDb *redis.Client
SystemSetting *systemSetting.SystemSettingCache
SystemMonitor cache.Cacher[interface{}]
RateLimit *RateLimiter
Expand Down
37 changes: 0 additions & 37 deletions service/global/queue.go

This file was deleted.

3 changes: 0 additions & 3 deletions service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/google/uuid v1.3.0
github.com/mojocn/base64Captcha v1.3.5
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/redis/go-redis/v9 v9.0.5
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/shirou/gopsutil/v3 v3.23.3
gitlab.com/tingshuo/go-diskstate v0.0.0-20191211131809-ee5e7223d03c
Expand All @@ -27,9 +26,7 @@ require (
require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
Expand Down
8 changes: 0 additions & 8 deletions service/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJs
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=
github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
Expand Down Expand Up @@ -83,8 +77,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/redis/go-redis/v9 v9.0.5 h1:CuQcn5HIEeK7BgElubPP8CGtE0KakrnbBSTLjathl5o=
github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
Expand Down
25 changes: 0 additions & 25 deletions service/initialize/A_ENTER.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (
"sun-panel/initialize/database"
"sun-panel/initialize/lang"
"sun-panel/initialize/other"
"sun-panel/initialize/redis"
"sun-panel/initialize/runlog"
"sun-panel/initialize/systemSettingCache"
"sun-panel/initialize/userToken"
"sun-panel/lib/cmn"
"sun-panel/models"
"sun-panel/structs"
"time"

"log"
Expand Down Expand Up @@ -59,29 +57,6 @@ func InitApp() error {

DatabaseConnect()

// Redis 连接
{
// 判断是否有使用redis的驱动,没有将不连接
cacheDrive := global.Config.GetValueString("base", "cache_drive")
queueDrive := global.Config.GetValueString("base", "queue_drive")
if cacheDrive == "redis" || queueDrive == "redis" {
redisConfig := structs.IniConfigRedis{}
global.Config.GetSection("redis", &redisConfig)
rdb, err := redis.InitRedis(redis.Options{
Addr: redisConfig.Address,
Password: redisConfig.Password,
DB: redisConfig.Db,
})

if err != nil {
log.Panicln("Redis initialization error", err)
panic(err)
// return err
}
global.RedisDb = rdb
}
}

// 初始化用户token
global.UserToken = userToken.InitUserToken()
global.CUserToken = cUserToken.InitCUserToken()
Expand Down
5 changes: 2 additions & 3 deletions service/initialize/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
func getDefaultConfig() map[string]map[string]string {
return map[string]map[string]string{
"base": {
"http_port": "9090",
"source_path": "./files", // 存放文件的路径
"source_temp_path": "./files/temp", // 存放文件的缓存路径
"http_port": "9090",
"source_path": "./files", // 存放文件的路径
},
"sqlite": {
"file_path": "./database.db",
Expand Down
Loading