Skip to content
Permalink
Browse files

Added a watch option on local applications to enable/disable path watch

  • Loading branch information...
eko committed Jul 11, 2019
1 parent 43ddddb commit 69e8457c09c4fdf9f7f0c490f34af2121a984c07
Showing with 17 additions and 96 deletions.
  1. +2 −46 README.md
  2. +7 −46 example.yaml
  3. +1 −0 internal/config/model.go
  4. +7 −4 pkg/watcher/watcher.go
@@ -111,6 +111,7 @@ gopath: /Users/vincent/golang # Optional, default to user's $GOPATH env var
<: &graphql-local
name: graphql
path: github.com/acme/graphql # Will find in GOPATH (as executable is "go")
watch: true # Default: false (do not watch directory)
executable: go
args:
- run
@@ -119,27 +120,12 @@ gopath: /Users/vincent/golang # Optional, default to user's $GOPATH env var
<: &grpc-api-local
name: grpc-api
path: github.com/acme/grpc-api # Will find in GOPATH (as executable is "go")
watch: true # Default: false (do not watch directory)
executable: go
args:
- run
- main.go
<: &search-api-local
name: search-api
path: github.com/acme/search-api # Will find in GOPATH (as executable is "go")
executable: go
args:
- run
- main.go
<: &pub-front-local
name: pub-front
path: /Users/vincent/dev/pub-front
executable: npm
args:
- run
- start
<: &elasticsearch-local
name: elasticsearch
path: /Users/vincent/dev/docker
@@ -177,30 +163,6 @@ gopath: /Users/vincent/golang # Optional, default to user's $GOPATH env var
ports:
- 8080:8080
<: &search-api-forward
name: search-api
type: kubernetes
values:
context: *kubernetes-context
namespace: backend
labels:
app: search-api
hostname: search-api.svc.local # Optional
ports:
- 8080:8080
<: &pub-front-forward
name: pub-front
type: kubernetes
values:
context: *kubernetes-context
namespace: frontend
labels:
app: pub-front
hostname: pub-front.svc.local # Optional
ports:
- 8080:8080
<: &composieux-fr
name: composieux-fr
type: ssh
@@ -217,24 +179,18 @@ projects:
local:
- *graphql-local
- *grpc-api-local
- *search-api-local
- *pub-front-local
- *elasticsearch-local
- name: graphql
local:
- *graphql-local
forward:
- *grpc-api-forward
- *search-api-forward
- *pub-front-forward
- name: forward-only
forward:
- *graphql-forward
- *grpc-api-forward
- *search-api-forward
- *pub-front-forward
```

@@ -7,6 +7,7 @@
<: &graphql-local
name: graphql
path: github.com/eko/graphql # Will find in GOPATH (as executable is "go")
watch: true # Default: false (do not watch directory)
executable: go
args:
- run
@@ -15,30 +16,16 @@
<: &grpc-api-local
name: grpc-api
path: github.com/eko/grpc-api # Will find in GOPATH (as executable is "go")
watch: true # Default: false (do not watch directory)
executable: go
args:
- run
- main.go

<: &search-api-local
name: search-api
path: github.com/eko/search-api # Will find in GOPATH (as executable is "go")
executable: go
args:
- run
- main.go

<: &pub-front-local
name: pub-front
path: /Users/vincent/dev/pub-front
executable: npm
args:
- run
- start

<: &elasticsearch-local
name: elasticsearch
path: /Users/vincent/dev/docker
watch: true # Default: false (do not watch directory)
executable: docker
args:
- start
@@ -73,30 +60,6 @@
ports:
- 8080:8080

<: &search-api-forward
name: search-api
type: kubernetes
values:
context: *kubernetes-context
namespace: backend
labels:
app: search-api
hostname: search-api.svc.local # Optional
ports:
- 8080:8080

<: &pub-front-forward
name: pub-front
type: kubernetes
values:
context: *kubernetes-context
namespace: frontend
labels:
app: pub-front
hostname: pub-front.svc.local # Optional
ports:
- 8080:8080

<: &composieux-fr
name: composieux-fr
type: ssh
@@ -113,21 +76,19 @@ projects:
local:
- *graphql-local
- *grpc-api-local
- *search-api-local
- *pub-front-local
- *elasticsearch-local

- name: graphql
local:
- *graphql-local
forward:
- *grpc-api-forward
- *search-api-forward
- *pub-front-forward

- name: forward-only
forward:
- *graphql-forward
- *grpc-api-forward
- *search-api-forward
- *pub-front-forward

- name: forward-composieux-website
forward:
- *composieux-fr
@@ -38,6 +38,7 @@ type Application struct {
Name string `yaml:"name"`
Path string `yaml:"path"`
Executable string `yaml:"executable"`
Watch bool `yaml:"watch"`
Args []string `yaml:"args"`
}

@@ -35,10 +35,13 @@ func (w *Watcher) Watch() {
w.runner.RunAll()

for _, application := range w.project.Applications {
err := w.watchApplication(application)
if err != nil {
fmt.Printf("❌ ERROR: %v\n", err)
if !application.Watch || application.Watch == false {
continue
}

fmt.Println(application.Name)

go w.watchApplication(application)
}
}

@@ -48,7 +51,7 @@ func (w *Watcher) watchApplication(application *config.Application) error {
fileWatcher.FilterOps(watcher.Write, watcher.Create, watcher.Remove)

if err := fileWatcher.AddRecursive(application.GetPath()); err != nil {
return err
fmt.Printf("❌ Unable to watch directory of application '%s': %v\n", application.Name, err)
}

go func() {

0 comments on commit 69e8457

Please sign in to comment.
You can’t perform that action at this time.