Skip to content

Commit

Permalink
Update service.ListRunning function to only return services for a spe…
Browse files Browse the repository at this point in the history
…cific core base on its name
  • Loading branch information
NicolasMahe committed Sep 20, 2018
1 parent 46a0b5c commit 462108b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions service/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (d *Dependency) Start(networkID string) (containerServiceID string, err err
Labels: map[string]string{
"mesg.service": d.service.Name,
"mesg.hash": d.service.ID,
"mesg.core": c.Core.Name,
},
Image: d.Image,
Args: strings.Fields(d.Command),
Expand Down
8 changes: 7 additions & 1 deletion service/status.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package service

import (
"github.com/mesg-foundation/core/config"
"github.com/mesg-foundation/core/container"
)

Expand Down Expand Up @@ -70,10 +71,15 @@ func (d *Dependency) Status() (container.StatusType, error) {
// ListRunning returns all the running services.2
// TODO: should move to another file
func ListRunning() ([]string, error) {
services, err := defaultContainer.ListServices("mesg.hash")
c, err := config.Global()
if err != nil {
return nil, err
}
services, err := defaultContainer.ListServices("mesg.hash", "mesg.core="+c.Core.Name)
if err != nil {
return nil, err
}
// Make service list unique. One mesg service can have multiple docker service.
mapRes := make(map[string]uint)
for _, service := range services {
serviceName := service.Spec.Annotations.Labels["mesg.hash"]
Expand Down

0 comments on commit 462108b

Please sign in to comment.