Exemple #1
0
func stopInstance(name string, instance string) {
	log.Debugln("Changing instance status to stop...")
	status := srv.GetServiceInstanceStatus(name, instance)
	if status == enum.STOPPED {
		log.Debugln("Instance already stopped")
		return
	}

	err := srv.ChangeServiceInstanceStatus(name, instance, status, enum.STOPPED)
	if err != nil {
		log.WithField("err", err).Errorln("Cannot stop service instance")
		return
	}

	log.Debugln("Updating events...")
	evt_mutex.Lock()
	srvEvents := events.Service[name]
	srvEvents.Stop = append(srvEvents.Stop, instance)
	events.Service[name] = srvEvents
	evt_mutex.Unlock()

	log.Debugln("Unregistering instance...")
	srv.UnregisterServiceInstance(name, instance)

	log.WithFields(log.Fields{
		"service": name,
		"id":      instance,
	}).Infoln("stopped instance")
}
Exemple #2
0
func promotePendingToRunning(name string, instance string) {
	srv.ChangeServiceInstanceStatus(name, instance, enum.PENDING, enum.RUNNING)
}