func ServiceExists(service *entities.Service) bool {
	GetServiceStatuses(service)
	if len(service.Status) == 1 &&
		service.Status[0].Status == ServiceStatusNotExists {
		return false
	}
	return true
}
ServiceExists - detects wether or not service exists in swarm
package swarm
import (
	"context"
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/api/types/events"
	"github.com/docker/docker/api/types/filters"
	"github.com/docker/docker/client"
	"github.com/dokkur/swanager/core/entities"
	"github.com/dokkur/swanager/core/swarm/network"
	swarm_service "github.com/dokkur/swanager/core/swarm/service"
)
const ServiceStatusNotExists = "not_exists"
func StartApplication(app *entities.Application) error {
	app.LoadServices()
	networkName := network.NameForDocker(app)
	network.Create(networkName)
	for _, service := range app.Services {
		swarm_service.Create(swarm_service.SpecOptions{
			Service:     &service,
			NetworkName: networkName,
		})
	}
	return nil
}
func StopApplication(app *entities.Application) error {
	app.LoadServices()
	for _, service := range app.Services {
		swarm_service.Remove(&service)
	}
	network.Remove(network.NameForDocker(app))
	return nil
}
func StartService(service *entities.Service) error {
	service.LoadApplication()
	networkName := network.NameForDocker(&service.Application)
	network.Create(networkName)
	_, err := swarm_service.Create(swarm_service.SpecOptions{
		Service:     service,
		NetworkName: networkName,
	})
	return err
}
func UpdateService(service *entities.Service) error {
	if !ServiceExists(service) {
		return nil
	}
	serviceInspection, _ := swarm_service.Inspect(service)
	service.LoadApplication()
	networkName := network.NameForDocker(&service.Application)
	return swarm_service.Update(swarm_service.SpecOptions{
		Service:     service,
		NetworkName: networkName,
		Index:       serviceInspection.Meta.Version.Index,
	})
}
func StopService(service *entities.Service) (err error) {
	err = swarm_service.Remove(service)
	network.Prune()
	return
}