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