Skip to content
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
file: ./shidai.Dockerfile
push: true
tags: ghcr.io/kiracore/sekin/shidai:${{ steps.create_tag.outputs.new_tag }}
build-args: |
VERSION=${{ steps.create_tag.outputs.new_tag }}
labels:
org.opencontainers.image.authors="kira.network"
org.opencontainers.image.url="https://github.com/KiraCore/sekin"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ syslog-data/*
test/*
src/shidai/test/*
shidai/*
.vscode
4 changes: 4 additions & 0 deletions src/shidai/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-github/v47 v47.1.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
Expand Down Expand Up @@ -139,6 +142,7 @@ require (
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions src/shidai/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v47 v47.1.0 h1:Cacm/WxQBOa9lF0FT0EMjZ2BWMetQ1TQfyurn4yF1z8=
github.com/google/go-github/v47 v47.1.0/go.mod h1:VPZBXNbFSJGjyjFRUKo9vZGawTajnWzC/YjGw/oFKi0=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -1394,6 +1400,8 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
7 changes: 6 additions & 1 deletion src/shidai/internal/api/api.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package api

import (
"context"

"github.com/gin-gonic/gin"
"github.com/kiracore/sekin/src/shidai/internal/commands"
"github.com/kiracore/sekin/src/shidai/internal/logger"
"github.com/kiracore/sekin/src/shidai/internal/types"
"github.com/kiracore/sekin/src/shidai/internal/update"
"go.uber.org/zap"
)

Expand All @@ -24,8 +27,10 @@ func Serve() {
router.GET("/status", infraStatus())
router.GET("/dashboard", getDashboardHandler())

go backgroundUpdate()
updateContext := context.Background()

go backgroundUpdate()
go update.UpdateRunner(updateContext)
if err := router.Run(":8282"); err != nil {
log.Error("Failed to start the server", zap.Error(err))
}
Expand Down
87 changes: 0 additions & 87 deletions src/shidai/internal/dashboard/dashboard.go

This file was deleted.

36 changes: 18 additions & 18 deletions src/shidai/internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log/syslog"
"os"
"path/filepath"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -16,20 +15,11 @@ func init() {

// File path for backup logging
logFilePath := "/syslog-data/syslog-ng/logs/shidai_backup.log"

logFileFolder := filepath.Dir(logFilePath)

if _, err := os.Stat(logFileFolder); os.IsNotExist(err) {
err = os.MkdirAll(logFileFolder, 0644)
if err != nil {
panic(fmt.Sprintf("Unable to create logs folder %s. %s", logFileFolder, err.Error()))
}
}

var logFileErrorCheck bool
// Create the log file if it does not exist, or open it in append mode if it does
logFile, err := os.OpenFile(logFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic("Unable to create/open the log file: " + err.Error())
logFileErrorCheck = true
}

// Setting up network syslog writer
Expand All @@ -45,15 +35,25 @@ func init() {
jsonEncoder := zapcore.NewJSONEncoder(encoderConfig)
plaintextEncoder := zapcore.NewConsoleEncoder(encoderConfig)

// Create cores for each output
fileCore := zapcore.NewCore(jsonEncoder, zapcore.AddSync(logFile), zap.NewAtomicLevelAt(zapcore.InfoLevel))
syslogCore := zapcore.NewCore(plaintextEncoder, zapcore.AddSync(syslogWriter), zap.NewAtomicLevelAt(zapcore.DebugLevel))

// Combine cores
combinedCore := zapcore.NewTee(fileCore, syslogCore)
var combinedCore zapcore.Core
if !logFileErrorCheck {
fmt.Println("LOGGER: is running with file writer")
// Create cores for each output
fileCore := zapcore.NewCore(jsonEncoder, zapcore.AddSync(logFile), zap.NewAtomicLevelAt(zapcore.InfoLevel))
syslogCore := zapcore.NewCore(plaintextEncoder, zapcore.AddSync(syslogWriter), zap.NewAtomicLevelAt(zapcore.DebugLevel))

// Combine cores
combinedCore = zapcore.NewTee(fileCore, syslogCore)
} else {
fmt.Println("LOGGER: is running without file writer")
stdoutCore := zapcore.NewCore(plaintextEncoder, zapcore.AddSync(os.Stdout), zap.NewAtomicLevelAt(zapcore.DebugLevel))
syslogCore := zapcore.NewCore(plaintextEncoder, zapcore.AddSync(syslogWriter), zap.NewAtomicLevelAt(zapcore.DebugLevel))
combinedCore = zapcore.NewTee(syslogCore, stdoutCore)
}

// Create the logger with the combined cores
log = zap.New(combinedCore, zap.AddCaller(), zap.AddStacktrace(zapcore.ErrorLevel))

}

func GetLogger() *zap.Logger { return log }
8 changes: 8 additions & 0 deletions src/shidai/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import (
)

type (
SekinPackagesVersion struct {
Sekai string
Interx string
Shidai string
}

InfraFiles map[string]string

AppInfo struct {
Expand Down Expand Up @@ -273,6 +279,8 @@ const (

DirPermRO os.FileMode = 0555
DirPermWR os.FileMode = 0755

UPDATER_BIN_PATH = "/updater"
)

var (
Expand Down
9 changes: 9 additions & 0 deletions src/shidai/internal/update/github_helper/githubHelper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package githubhelper

import "github.com/kiracore/sekin/src/shidai/internal/types"

type GithubTestHelper struct{}

func (GithubTestHelper) GetLatestSekinVersion() (*types.SekinPackagesVersion, error) {
return &types.SekinPackagesVersion{Sekai: "v0.3.45", Interx: "v0.4.49", Shidai: "v0.9.0"}, nil
}
Loading
Loading