Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "rrb", Short: "A filesystem watcher that runs commands on changes", Long: "This command watches the filesystem and waits for file changes. When it " + "happens, it invokes the given command. If a command was already being previously " + "executed, then its process tree is gracefully terminated, before running the " + "command again.", Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { logrus.Fatal("Missing build command.") os.Exit(1) } w, err := watcher.NewWatcher(watcher.Config{ RootPath: directory, Patterns: patterns, IgnorePatterns: ignorePatterns, DebounceDuration: debounce, }) if err != nil { logrus.Fatalf("NewWatcher: %s", err.Error()) } defer w.Close() r := runner.NewRunner(killWait, args[0], args[1:]...) sigCn := make(chan os.Signal, 1) signal.Notify(sigCn, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP) for { select { case <-w.ChangedFilesCn: if err := r.Run(); err != nil { logrus.Fatal(err) } case err := <-w.ErrorsCn: logrus.Fatal(err) case sig := <-sigCn: logrus.Warnf("Signal %s received!", sig) r.Kill() logrus.Fatal("Exiting") } } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.