Skip to content

Commit

Permalink
HOTFIX: Fix watcher when too many files present
Browse files Browse the repository at this point in the history
  • Loading branch information
glinton committed Nov 1, 2017
1 parent 80207fe commit 1d2d69f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ _testmain.go
.DS_Store
TODO
nanobox
nanobox-updater
nanobox-*
updater/updater
updater/updater-*
.build
rsrc.syso
Icon
Expand Down
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
TAG=`git describe --always --tags --abbrev=0 | tr -d "[v\r\n]"`
COMMIT=`git rev-parse --short HEAD | tr -d "[ \r\n\']"`
BUILD_DATE=`date -u +%y%m%dT%H%M`
GITSTATUS='$(shell git status 2> /dev/null | tail -n1)'
DIRTY="$(shell [ $(GITSTATUS) = 'no changes added to commit (use "git add" and/or "git commit -a")' ] && echo -n "*")"
GO_LDFLAGS="-s -X github.com/nanobox-io/nanobox/util/odin.apiKey=$(API_KEY) -X github.com/nanobox-io/nanobox/models.nanoVersion=$(TAG) -X github.com/nanobox-io/nanobox/models.nanoCommit=$(COMMIT)$(DIRTY) -X github.com/nanobox-io/nanobox/models.nanoBuild=$(BUILD_DATE)"

default: build

clean:
@echo "Cleaning old builds"
@rm -rf "./.build"

# go get github.com/mitchellh/gox
build: clean
@echo "Building nanobox"
@gox -ldflags=$(GO_LDFLAGS) -osarch "darwin/amd64 linux/amd64 windows/amd64" -output="./.build/v2/{{.OS}}/{{.Arch}}/nanobox"
@echo -en "Nanobox Version $(TAG)-$(BUILD_DATE) ($(COMMIT))" > ./.build/v2/version
@echo "Building nanobox-update"
@cd ./updater && gox -osarch "darwin/amd64 linux/amd64 windows/amd64" -ldflags="-s" -output="../.build/v2/{{.OS}}/{{.Arch}}/nanobox-update"

linux:
@echo "Building nanobox-linux"
@GOOS=linux go build -ldflags=$(GO_LDFLAGS) -o nanobox-linux

windows:
@echo "Building nanobox-windows"
@GOOS=windows go build -ldflags=$(GO_LDFLAGS) -o nanobox-windows

darwin:
@echo "Building nanobox-darwin"
@GOOS=darwin go build -ldflags=$(GO_LDFLAGS) -o nanobox-darwin

# go get github.com/kardianos/govendor
test:
@govendor test +local -v


.PHONY: fmt test clean build linux windows darwin
1 change: 0 additions & 1 deletion util/service/remove_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ func Remove(name string) error {

os.Remove(serviceConfigFile(name))
return nil

}
1 change: 1 addition & 0 deletions util/watch/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func newRecursiveWatcher(path string) (Watcher, error) {
lumber.Info("Adding %s", folders[i])
err = notifyWatcher.Add(folders[i])
if err != nil {
watcher.Close()
return nil, err
}
}
Expand Down
3 changes: 1 addition & 2 deletions util/watch/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func Watch(container, path string) error {

// try watching with the fast one
watcher, err := newRecursiveWatcher("./")
defer watcher.close()
if err != nil {
// if it fails display a message and try the slow one
lumber.Info("Error occured in fast notify watcher: %s", err.Error())
Expand All @@ -51,7 +50,6 @@ func Watch(container, path string) error {
fmt.Printf("Until then, we'll go ahead and rollover to a slower polling solution.\n\r")
fmt.Printf("\n\r---------------------------------------------------------------------\n\r\n\r")

watcher.close()
watcher = newCrawlWatcher(path)
err := watcher.watch()
if err != nil {
Expand All @@ -61,6 +59,7 @@ func Watch(container, path string) error {
} else {
go run(watcher.(*notify))
}
defer watcher.close()

go batchPublish(container)

Expand Down

0 comments on commit 1d2d69f

Please sign in to comment.