remove .Debug()
This commit is contained in:
parent
026e981415
commit
dc4f17952e
6 changed files with 12 additions and 14 deletions
|
@ -9,7 +9,7 @@ COPY . .
|
|||
RUN go build -o aides-repo-api ./cmd/aides-repo-api/main.go
|
||||
|
||||
# Второй этап: создание финального образа
|
||||
FROM registry.altlinux.org/alt/alt:sisyphus
|
||||
FROM registry.altlinux.org/sisyphus/alt:20241211
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
gormlogger "gorm.io/gorm/logger"
|
||||
"moul.io/zapgorm2"
|
||||
|
||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config"
|
||||
|
@ -52,6 +53,7 @@ func (app *App) createLogger() {
|
|||
|
||||
func (app *App) createDb() {
|
||||
logger := zapgorm2.New(app.logger.GetZap())
|
||||
logger.LogMode(gormlogger.Info)
|
||||
logger.SetAsDefault()
|
||||
dsn := fmt.Sprintf(
|
||||
"host=%s port=%s user=%s password=%s dbname=%s sslmode=disable",
|
||||
|
|
|
@ -2,7 +2,6 @@ package cronservice
|
|||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/go-co-op/gocron/v2"
|
||||
|
||||
|
@ -20,7 +19,7 @@ type Service struct {
|
|||
}
|
||||
|
||||
func New(repo RepoService) *Service {
|
||||
scheduler, err := gocron.NewScheduler(gocron.WithLocation(time.UTC))
|
||||
scheduler, err := gocron.NewScheduler()
|
||||
if err != nil {
|
||||
log.Fatalf("Не удалось создать планировщик: %v", err)
|
||||
}
|
||||
|
@ -33,11 +32,11 @@ func New(repo RepoService) *Service {
|
|||
|
||||
func (s *Service) SetupCronJobs() {
|
||||
_, err := s.scheduler.NewJob(
|
||||
gocron.CronJob("* * * * *", false),
|
||||
gocron.CronJob("0 4 * * *", false),
|
||||
gocron.NewTask(func() {
|
||||
log := logger.GetLogger()
|
||||
log.Info(
|
||||
"Cron run!",
|
||||
"[cron] force update is started",
|
||||
)
|
||||
s.repoService.ForceUpdate()
|
||||
}),
|
||||
|
|
|
@ -53,8 +53,8 @@ func runGenbasedir(repoDir, arch, repoName string) {
|
|||
arch,
|
||||
repoName,
|
||||
)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = nil
|
||||
cmd.Stderr = nil
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Error(
|
||||
|
@ -106,7 +106,7 @@ func (s *Service) ForceUpdate() {
|
|||
Where(&altRepo).
|
||||
First(&altRepo)
|
||||
|
||||
s.db.Debug().
|
||||
s.db.
|
||||
Model(&models.GitRepoAltRepoTask{}).
|
||||
Select("tasks.*").
|
||||
Joins("JOIN tasks ON tasks.id = git_repo_alt_repo_tasks.last_task_id").
|
||||
|
@ -158,7 +158,7 @@ func (s *Service) ForceUpdate() {
|
|||
runGenbasedir(repoPath, arch, repoName)
|
||||
}
|
||||
|
||||
s.db.Debug().
|
||||
s.db.
|
||||
Model(&models.GitRepoAltRepoTask{}).
|
||||
Where(&models.GitRepoAltRepoTask{
|
||||
ALTRepoID: altRepo.ID,
|
||||
|
|
|
@ -8,7 +8,7 @@ func (s *Service) Create(repo string) (*models.Task, error) {
|
|||
taskRepo := models.GitRepo{
|
||||
Name: repo,
|
||||
}
|
||||
s.db.Debug().
|
||||
s.db.
|
||||
Where(&taskRepo).
|
||||
FirstOrCreate(&taskRepo)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s *Service) onTaskComplete(task *models.Task) error {
|
|||
ALTRepoID: 1,
|
||||
RepoID: task.RepoID,
|
||||
}
|
||||
s.db.Debug().
|
||||
s.db.
|
||||
Where(&grart).
|
||||
FirstOrCreate(&grart)
|
||||
|
||||
|
@ -61,7 +61,6 @@ func (s *Service) tasksCleanup(r *models.GitRepoAltRepoTask, n int) {
|
|||
|
||||
var lastNTaskIDs []uint
|
||||
s.db.
|
||||
Debug().
|
||||
Table("tasks").
|
||||
Select("id").
|
||||
Where("repo_id = ?", r.ID).
|
||||
|
@ -75,7 +74,6 @@ func (s *Service) tasksCleanup(r *models.GitRepoAltRepoTask, n int) {
|
|||
|
||||
var taskIDsToDelete []int
|
||||
s.db.
|
||||
Debug().
|
||||
Model(&models.Task{}).
|
||||
Select("id").
|
||||
Where("repo_id = ?", r.RepoID).
|
||||
|
@ -85,7 +83,6 @@ func (s *Service) tasksCleanup(r *models.GitRepoAltRepoTask, n int) {
|
|||
|
||||
if len(taskIDsToDelete) > 0 {
|
||||
s.db.
|
||||
Debug().
|
||||
Model(&models.Task{}).
|
||||
Where("id IN ?", taskIDsToDelete).
|
||||
Update("files_removed", true)
|
||||
|
|
Loading…
Reference in a new issue