refactor(cmd/joj3): load attr in conf module
All checks were successful
submodules sync / sync (push) Successful in 38s
build / build (push) Successful in 1m20s
build / trigger-build-image (push) Successful in 7s

This commit is contained in:
张泊明518370910136 2024-11-15 20:14:10 -05:00
parent 01d5c635d4
commit 8c48c0e4ee
GPG Key ID: D47306D7062CDA9D
2 changed files with 2 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import (
"time" "time"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
"github.com/joint-online-judge/JOJ3/internal/stage" "github.com/joint-online-judge/JOJ3/internal/stage"
"github.com/koding/multiconfig" "github.com/koding/multiconfig"
) )
@ -169,6 +170,7 @@ func ParseConfFile(path string) (conf *Conf, err error) {
slog.Error("validate stages conf", "error", err) slog.Error("validate stages conf", "error", err)
return return
} }
env.Attr.ConfName = conf.Name
// TODO: remove the following backward compatibility codes // TODO: remove the following backward compatibility codes
if len(conf.Stage.Stages) == 0 { if len(conf.Stage.Stages) == 0 {
conf.Stage.SandboxExecServer = conf.SandboxExecServer conf.Stage.SandboxExecServer = conf.SandboxExecServer

View File

@ -7,7 +7,6 @@ import (
"os" "os"
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf" "github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
"github.com/joint-online-judge/JOJ3/cmd/joj3/env"
"github.com/joint-online-judge/JOJ3/cmd/joj3/stage" "github.com/joint-online-judge/JOJ3/cmd/joj3/stage"
"github.com/joint-online-judge/JOJ3/cmd/joj3/teapot" "github.com/joint-online-judge/JOJ3/cmd/joj3/teapot"
internalStage "github.com/joint-online-judge/JOJ3/internal/stage" internalStage "github.com/joint-online-judge/JOJ3/internal/stage"
@ -87,7 +86,6 @@ func mainImpl() (err error) {
return err return err
} }
slog.Debug("conf loaded", "conf", confObj) slog.Debug("conf loaded", "conf", confObj)
env.Attr.ConfName = confObj.Name
if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded if err := setupSlog(confObj.LogPath); err != nil { // after conf is loaded
slog.Error("setup slog", "error", err) slog.Error("setup slog", "error", err)
return err return err