Example #1
0
func deploy() {
	// fetch all go dependencies
	if nil != settings.Dependencies {
		golang.FetchDependencies(*settings.Dependencies)
	}

	if nil != settings.ClosureArtifacts {
		err := closure.Regenerate(filepath.Join(workingDir, *settings.StaticDir),
			func(base string) error {
				return closure.GenerateTemplates(base,
					filepath.Join(base, settings.ClosureArtifacts.ArtifactDir),
					settings.ClosureArtifacts.Templates)
			},
			func(base string) error {
				if nil != settings.ClosureArtifacts.CSS {
					closure.ProcessCSSMulti(base, "CLOSURE",
						*settings.ClosureArtifacts.CSS)
				}
				return nil
			}, func(base string) error {
				if nil != settings.ClosureArtifacts.JS {
					closure.JSCompileMulti(base, revision,
						*settings.ClosureArtifacts.JS)
				}
				return nil
			})
		if nil != err {
			log.Fatalf("Error processing closure files.\nError: %s", err)
		}
	}

	appengine.Deploy(workingDir)
}
Example #2
0
func debug() {
	// fetch all go dependencies
	if nil != settings.Dependencies {
		golang.FetchDependencies(*settings.Dependencies)
	}

	regen()

	if nil != settings.StaticDir {
		watcher, err := fsnotify.NewWatcher()
		if nil != err {
			log.Fatalf("Unable to setup source file monitor. Error: %s", err)
		}
		defer watcher.Close()

		var artifactDir *string
		staticDir := filepath.Join(workingDir, *settings.StaticDir)
		if nil != settings.ClosureArtifacts {
			a := filepath.Join(staticDir, settings.ClosureArtifacts.ArtifactDir)
			artifactDir = &a
		}

		go func() {
			for {
				select {
				case event := <-watcher.Events:
					path := event.Name
					if nil != settings.ClosureArtifacts && strings.HasPrefix(path, *artifactDir) {
						continue
					}
					skip := false
					for _, r := range FileWatchExcludes {
						if r.MatchString(path) {
							skip = true
							break
						}
					}
					if skip {
						continue
					}
					log.Printf("File '%s' changed, regenerating closure artifacts",
						path)
					log.Printf("Change type: %d", event.Op)
					regen()
				}
			}
		}()

		if err = filepath.Walk(staticDir, func(path string, info os.FileInfo, err error) error {
			if nil != err {
				return nil
			}
			if !info.IsDir() {
				return nil
			}
			if nil != artifactDir && strings.HasPrefix(path, *artifactDir) {
				return nil
			}
			for _, r := range FileWatchExcludes {
				if r.MatchString(path) {
					return nil
				}
			}
			log.Printf("Watching: %s", path)
			watcher.Add(path)
			return nil
		}); nil != err {
			log.Fatalf("Unable to set up static resource watching. Error: %s", err)
		}
	}

	if err := appengine.DevServer(workingDir); nil != err {
		log.Fatalf("Error starting Google App Engine dev server. Error: %s",
			err)
	}
}