File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ var svcRunCmd = &cobra.Command{
1212
1313 Run : func (cmd * cobra.Command , args []string ) {
1414 pm := support .NewPM (cfg )
15- pm .Run ()
15+ pm .Run (args )
1616 },
1717}
1818
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
1313
1414type PM struct {
1515 config Config
16+ services []string // Specific services to run, if empty, run all from config
1617}
1718
1819func NewPM (cfg Config ) * PM {
@@ -21,14 +22,30 @@ func NewPM(cfg Config) *PM {
2122 }
2223}
2324
24- func (pm * PM ) Run () {
25+ func (pm * PM ) Run (services []string ) {
26+ for _ , s := range services {
27+ hasService := false
28+ for name , _ := range pm .config .Services {
29+ if name == s {
30+ hasService = true
31+ }
32+ }
33+ if ! hasService {
34+ fmt .Println ("Could not find service " + s )
35+ os .Exit (1 )
36+ }
37+ }
38+ pm .services = services
2539 pm .start ()
2640 waitSig ()
2741 pm .stop ()
2842}
2943
3044func (pm * PM ) start () {
3145 for name , svc := range pm .config .Services {
46+ if len (pm .services ) != 0 && ! StringInSlice (name , pm .services ) {
47+ continue
48+ }
3249 svc .name = name
3350
3451 if svc .Build != "" {
@@ -47,6 +64,9 @@ func (pm *PM) start() {
4764
4865func (pm * PM ) stop () {
4966 for _ , svc := range pm .config .Services {
67+ if len (pm .services ) != 0 && ! StringInSlice (svc .name , pm .services ) {
68+ continue
69+ }
5070 pm .kill (svc , true )
5171 }
5272}
You can’t perform that action at this time.
0 commit comments