|
|
@ -230,34 +230,17 @@ func LinkEvent(event Event, child Event, info EventInfo) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func StartRootEvent(event Event) error {
|
|
|
|
func RunEvent(event Event) error {
|
|
|
|
Log.Logf("event", "ROOT_EVEN_START")
|
|
|
|
Log.Logf("event", "EVENT_RUN: %s", event.Name())
|
|
|
|
|
|
|
|
|
|
|
|
err := LockResources(event)
|
|
|
|
for _, resource := range(event.Resources()) {
|
|
|
|
if err != nil {
|
|
|
|
if resource.Owner() == nil {
|
|
|
|
Log.Logf("event", "ROOT_EVENT_LOCK_ERR: %s", err)
|
|
|
|
return fmt.Errorf("EVENT_RUN_RESOURCE_NOT_LOCKED: %s, %s", event.Name(), resource.Name())
|
|
|
|
return err
|
|
|
|
} else if resource.Owner().ID() != event.ID() {
|
|
|
|
|
|
|
|
return fmt.Errorf("EVENT_RUN_RESOURCE_ALREADY_LOCKED: %s, %s, %s", event.Name(), resource.Name(), resource.Owner().Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = RunEvent(event)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
Log.Logf("event", "ROOT_EVENT_RUNE_ERR: %s", err)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = FinishEvent(event)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
Log.Logf("event", "ROOT_EVENT_FINISH_ERR: %s", err)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Log.Logf("event", "ROOT_EVENT_DONE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func RunEvent(event Event) error {
|
|
|
|
|
|
|
|
Log.Logf("event", "EVENT_RUN: %s", event.Name())
|
|
|
|
|
|
|
|
SendUpdate(event, NewSignal(event, "event_start"))
|
|
|
|
SendUpdate(event, NewSignal(event, "event_start"))
|
|
|
|
next_action := "start"
|
|
|
|
next_action := "start"
|
|
|
|
var err error = nil
|
|
|
|
var err error = nil
|
|
|
@ -275,6 +258,12 @@ func RunEvent(event Event) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = FinishEvent(event)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
Log.Logf("event", "EVENT_RUN_FINISH_ERR: %s", err)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.Logf("event", "EVENT_RUN_DONE: %s", event.Name())
|
|
|
|
Log.Logf("event", "EVENT_RUN_DONE: %s", event.Name())
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -525,7 +514,6 @@ func NewEventQueue(name string, description string, resources []Resource) (* Eve
|
|
|
|
Log.Logf("event", "EVENT_ERROR: %s", err)
|
|
|
|
Log.Logf("event", "EVENT_ERROR: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
info.state = "done"
|
|
|
|
info.state = "done"
|
|
|
|
FinishEvent(event)
|
|
|
|
|
|
|
|
}(event, info, queue)
|
|
|
|
}(event, info, queue)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|