Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
only load service associated to a timer when update
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rad committed Dec 11, 2015
1 parent 03fb6b9 commit 750700e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type ServiceManifest struct {
}

type Service interface {
HasTimer() bool
PrepareAciList() string
NodeAttributes(hostname string) map[string]interface{}
GetAttributes() map[string]interface{}
Expand Down
4 changes: 4 additions & 0 deletions work/env/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (s *Service) prepareNodesAsJsonMap() {
s.nodesAsJsonMap = res
}

func (s *Service) HasTimer() bool {
return s.hasTimer
}

func (s *Service) GetAttributes() map[string]interface{} {
return s.attributes
}
Expand Down
5 changes: 5 additions & 0 deletions work/env/service/unit-command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"github.com/Sirupsen/logrus"
"github.com/blablacar/ggn/builder"
"github.com/blablacar/ggn/spec"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -42,6 +43,10 @@ func (u *Unit) Destroy(command string) error {

func (u *Unit) Restart(command string) error {
u.Log.Debug("restart")
if u.Type == spec.TYPE_SERVICE && u.Service.HasTimer() {
u.Log.Fatal("You cannot restart a service associated to a time")
}

u.runHook(EARLY, command, "restart")
defer u.runHook(LATE, command, "restart")

Expand Down
6 changes: 5 additions & 1 deletion work/env/service/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ func (u *Unit) GetUnitContentAsFleeted() (string, error) {
func (u *Unit) UpdateInside(command string) {
u.Destroy(command)
time.Sleep(time.Second * 2)
u.Start(command)
if u.Type == spec.TYPE_SERVICE && u.Service.HasTimer() {
u.Load(command)
} else {
u.Start(command)
}
}

func (u *Unit) DisplayDiff() error {
Expand Down

0 comments on commit 750700e

Please sign in to comment.