mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
refactor(stack): stack build process backend only [EE-4342] (#7750)
This commit is contained in:
parent
83a1ce9d2a
commit
e9de484c3e
65 changed files with 2270 additions and 942 deletions
35
api/stacks/deployments/autoupdate.go
Normal file
35
api/stacks/deployments/autoupdate.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package deployments
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
httperror "github.com/portainer/libhttp/error"
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/dataservices"
|
||||
"github.com/portainer/portainer/api/scheduler"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func StartAutoupdate(stackID portainer.StackID, interval string, scheduler *scheduler.Scheduler, stackDeployer StackDeployer, datastore dataservices.DataStore, gitService portainer.GitService) (jobID string, e *httperror.HandlerError) {
|
||||
d, err := time.ParseDuration(interval)
|
||||
if err != nil {
|
||||
return "", httperror.BadRequest("Unable to parse stack's auto update interval", err)
|
||||
}
|
||||
|
||||
jobID = scheduler.StartJobEvery(d, func() error {
|
||||
return RedeployWhenChanged(stackID, stackDeployer, datastore, gitService)
|
||||
})
|
||||
|
||||
return jobID, nil
|
||||
}
|
||||
|
||||
func StopAutoupdate(stackID portainer.StackID, jobID string, scheduler *scheduler.Scheduler) {
|
||||
if jobID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
if err := scheduler.StopJob(jobID); err != nil {
|
||||
log.Warn().Int("stack_id", int(stackID)).Msg("could not stop the job for the stack")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue