1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
30 "git.arvados.org/arvados.git/lib/config"
31 "git.arvados.org/arvados.git/lib/service"
32 "git.arvados.org/arvados.git/sdk/go/arvados"
33 "git.arvados.org/arvados.git/sdk/go/ctxlog"
34 "git.arvados.org/arvados.git/sdk/go/health"
35 "github.com/fsnotify/fsnotify"
36 "github.com/sirupsen/logrus"
39 type Supervisor struct {
40 SourcePath string // e.g., /home/username/src/arvados
41 SourceVersion string // e.g., acbd1324...
42 ClusterType string // e.g., production
43 ListenHost string // e.g., localhost
44 ControllerAddr string // e.g., 127.0.0.1:8000
45 Workbench2Source string // e.g., /home/username/src/arvados-workbench2
48 OwnTemporaryDatabase bool
51 logger logrus.FieldLogger
52 cluster *arvados.Cluster
55 cancel context.CancelFunc
56 done chan struct{} // closed when child procs/services have shut down
57 err error // error that caused shutdown (valid when done is closed)
58 healthChecker *health.Aggregator
59 tasksReady map[string]chan bool
60 waitShutdown sync.WaitGroup
63 tempdir string // in production mode, this is accessible only to root
64 wwwtempdir string // in production mode, this is accessible only to www-data
66 environ []string // for child processes
69 func (super *Supervisor) Cluster() *arvados.Cluster { return super.cluster }
71 func (super *Supervisor) Start(ctx context.Context, cfg *arvados.Config, cfgPath string) {
72 super.ctx, super.cancel = context.WithCancel(ctx)
73 super.done = make(chan struct{})
76 defer close(super.done)
78 sigch := make(chan os.Signal)
79 signal.Notify(sigch, syscall.SIGINT, syscall.SIGTERM)
80 defer signal.Stop(sigch)
82 for sig := range sigch {
83 super.logger.WithField("signal", sig).Info("caught signal")
85 super.err = fmt.Errorf("caught signal %s", sig)
91 hupch := make(chan os.Signal)
92 signal.Notify(hupch, syscall.SIGHUP)
93 defer signal.Stop(hupch)
95 for sig := range hupch {
96 super.logger.WithField("signal", sig).Info("caught signal")
98 super.err = errNeedConfigReload
104 if cfgPath != "" && cfgPath != "-" && cfg.AutoReloadConfig {
105 go watchConfig(super.ctx, super.logger, cfgPath, copyConfig(cfg), func() {
106 if super.err == nil {
107 super.err = errNeedConfigReload
113 err := super.run(cfg)
115 super.logger.WithError(err).Warn("supervisor shut down")
116 if super.err == nil {
123 func (super *Supervisor) Wait() error {
128 func (super *Supervisor) run(cfg *arvados.Config) error {
131 cwd, err := os.Getwd()
135 if !strings.HasPrefix(super.SourcePath, "/") {
136 super.SourcePath = filepath.Join(cwd, super.SourcePath)
138 super.SourcePath, err = filepath.EvalSymlinks(super.SourcePath)
143 // Choose bin and temp dirs: /var/lib/arvados/... in
144 // production, transient tempdir otherwise.
145 if super.ClusterType == "production" {
146 // These dirs have already been created by
147 // "arvados-server install" (or by extracting a
149 super.tempdir = "/var/lib/arvados/tmp"
150 super.wwwtempdir = "/var/lib/arvados/wwwtmp"
151 super.bindir = "/var/lib/arvados/bin"
153 super.tempdir, err = ioutil.TempDir("", "arvados-server-boot-")
157 defer os.RemoveAll(super.tempdir)
158 super.wwwtempdir = super.tempdir
159 super.bindir = filepath.Join(super.tempdir, "bin")
160 if err := os.Mkdir(super.bindir, 0755); err != nil {
165 // Fill in any missing config keys, and write the resulting
166 // config in the temp dir for child services to use.
167 err = super.autofillConfig(cfg)
171 conffile, err := os.OpenFile(filepath.Join(super.wwwtempdir, "config.yml"), os.O_CREATE|os.O_WRONLY, 0644)
175 defer conffile.Close()
176 err = json.NewEncoder(conffile).Encode(cfg)
180 err = conffile.Close()
184 super.configfile = conffile.Name()
186 super.environ = os.Environ()
187 super.cleanEnv([]string{"ARVADOS_"})
188 super.setEnv("ARVADOS_CONFIG", super.configfile)
189 super.setEnv("RAILS_ENV", super.ClusterType)
190 super.setEnv("TMPDIR", super.tempdir)
191 super.prependEnv("PATH", "/var/lib/arvados/bin:")
192 if super.ClusterType != "production" {
193 super.prependEnv("PATH", super.tempdir+"/bin:")
196 super.cluster, err = cfg.GetCluster("")
200 // Now that we have the config, replace the bootstrap logger
201 // with a new one according to the logging config.
202 loglevel := super.cluster.SystemLogs.LogLevel
203 if s := os.Getenv("ARVADOS_DEBUG"); s != "" && s != "0" {
206 super.logger = ctxlog.New(super.Stderr, super.cluster.SystemLogs.Format, loglevel).WithFields(logrus.Fields{
210 if super.SourceVersion == "" && super.ClusterType == "production" {
211 // don't need SourceVersion
212 } else if super.SourceVersion == "" {
213 // Find current source tree version.
215 err = super.RunProgram(super.ctx, ".", runOptions{output: &buf}, "git", "diff", "--shortstat")
219 dirty := buf.Len() > 0
221 err = super.RunProgram(super.ctx, ".", runOptions{output: &buf}, "git", "log", "-n1", "--format=%H")
225 super.SourceVersion = strings.TrimSpace(buf.String())
227 super.SourceVersion += "+uncommitted"
230 return errors.New("specifying a version to run is not yet supported")
233 _, err = super.installGoProgram(super.ctx, "cmd/arvados-server")
237 err = super.setupRubyEnv()
242 tasks := []supervisedTask{
243 createCertificates{},
246 runServiceCommand{name: "controller", svc: super.cluster.Services.Controller, depends: []supervisedTask{seedDatabase{}}},
247 runGoProgram{src: "services/arv-git-httpd", svc: super.cluster.Services.GitHTTP},
248 runGoProgram{src: "services/health", svc: super.cluster.Services.Health},
249 runServiceCommand{name: "keepproxy", svc: super.cluster.Services.Keepproxy, depends: []supervisedTask{runPassenger{src: "services/api"}}},
250 runServiceCommand{name: "keepstore", svc: super.cluster.Services.Keepstore},
251 runGoProgram{src: "services/keep-web", svc: super.cluster.Services.WebDAV},
252 runServiceCommand{name: "ws", svc: super.cluster.Services.Websocket, depends: []supervisedTask{seedDatabase{}}},
253 installPassenger{src: "services/api"},
254 runPassenger{src: "services/api", varlibdir: "railsapi", svc: super.cluster.Services.RailsAPI, depends: []supervisedTask{createCertificates{}, seedDatabase{}, installPassenger{src: "services/api"}}},
257 if !super.NoWorkbench1 {
258 tasks = append(tasks,
259 installPassenger{src: "apps/workbench", depends: []supervisedTask{seedDatabase{}}}, // dependency ensures workbench doesn't delay api install/startup
260 runPassenger{src: "apps/workbench", varlibdir: "workbench1", svc: super.cluster.Services.Workbench1, depends: []supervisedTask{installPassenger{src: "apps/workbench"}}},
263 if !super.NoWorkbench2 {
264 tasks = append(tasks,
265 runWorkbench2{svc: super.cluster.Services.Workbench2},
268 if super.ClusterType != "test" {
269 tasks = append(tasks,
270 runServiceCommand{name: "dispatch-cloud", svc: super.cluster.Services.DispatchCloud},
271 runGoProgram{src: "services/keep-balance", svc: super.cluster.Services.Keepbalance},
274 super.tasksReady = map[string]chan bool{}
275 for _, task := range tasks {
276 super.tasksReady[task.String()] = make(chan bool)
278 for _, task := range tasks {
280 fail := func(err error) {
281 if super.ctx.Err() != nil {
285 super.logger.WithField("task", task.String()).WithError(err).Error("task failed")
288 super.logger.WithField("task", task.String()).Info("starting")
289 err := task.Run(super.ctx, fail, super)
294 close(super.tasksReady[task.String()])
297 err = super.wait(super.ctx, tasks...)
301 super.logger.Info("all startup tasks are complete; starting health checks")
302 super.healthChecker = &health.Aggregator{Cluster: super.cluster}
304 super.logger.Info("shutting down")
305 super.waitShutdown.Wait()
306 return super.ctx.Err()
309 func (super *Supervisor) wait(ctx context.Context, tasks ...supervisedTask) error {
310 for _, task := range tasks {
311 ch, ok := super.tasksReady[task.String()]
313 return fmt.Errorf("no such task: %s", task)
315 super.logger.WithField("task", task.String()).Info("waiting")
318 super.logger.WithField("task", task.String()).Info("ready")
320 super.logger.WithField("task", task.String()).Info("task was never ready")
327 func (super *Supervisor) Stop() {
332 func (super *Supervisor) WaitReady() (*arvados.URL, bool) {
333 ticker := time.NewTicker(time.Second)
335 for waiting := "all"; waiting != ""; {
338 case <-super.ctx.Done():
341 if super.healthChecker == nil {
345 resp := super.healthChecker.ClusterHealth()
346 // The overall health check (resp.Health=="OK") might
347 // never pass due to missing components (like
348 // arvados-dispatch-cloud in a test cluster), so
349 // instead we wait for all configured components to
352 for target, check := range resp.Checks {
353 if check.Health != "OK" {
354 waiting += " " + target
358 super.logger.WithField("targets", waiting[1:]).Info("waiting")
361 u := super.cluster.Services.Controller.ExternalURL
365 func (super *Supervisor) prependEnv(key, prepend string) {
366 for i, s := range super.environ {
367 if strings.HasPrefix(s, key+"=") {
368 super.environ[i] = key + "=" + prepend + s[len(key)+1:]
372 super.environ = append(super.environ, key+"="+prepend)
375 func (super *Supervisor) cleanEnv(prefixes []string) {
377 for _, s := range super.environ {
379 for _, p := range prefixes {
380 if strings.HasPrefix(s, p) {
386 cleaned = append(cleaned, s)
389 super.environ = cleaned
392 func (super *Supervisor) setEnv(key, val string) {
393 for i, s := range super.environ {
394 if strings.HasPrefix(s, key+"=") {
395 super.environ[i] = key + "=" + val
399 super.environ = append(super.environ, key+"="+val)
402 // Remove all but the first occurrence of each env var.
403 func dedupEnv(in []string) []string {
404 saw := map[string]bool{}
406 for _, kv := range in {
407 if split := strings.Index(kv, "="); split < 1 {
408 panic("invalid environment var: " + kv)
409 } else if saw[kv[:split]] {
412 saw[kv[:split]] = true
413 out = append(out, kv)
419 func (super *Supervisor) installGoProgram(ctx context.Context, srcpath string) (string, error) {
420 _, basename := filepath.Split(srcpath)
421 binfile := filepath.Join(super.bindir, basename)
422 if super.ClusterType == "production" {
425 err := super.RunProgram(ctx, filepath.Join(super.SourcePath, srcpath), runOptions{env: []string{"GOBIN=" + super.bindir}}, "go", "install", "-ldflags", "-X git.arvados.org/arvados.git/lib/cmd.version="+super.SourceVersion+" -X main.version="+super.SourceVersion)
429 func (super *Supervisor) usingRVM() bool {
430 return os.Getenv("rvm_path") != ""
433 func (super *Supervisor) setupRubyEnv() error {
434 if !super.usingRVM() {
435 // (If rvm is in use, assume the caller has everything
436 // set up as desired)
437 super.cleanEnv([]string{
442 if _, err := os.Stat("/var/lib/arvados/bin/gem"); err == nil || super.ClusterType == "production" {
443 gem = "/var/lib/arvados/bin/gem"
445 cmd := exec.Command(gem, "env", "gempath")
446 if super.ClusterType == "production" {
447 cmd.Args = append([]string{"sudo", "-u", "www-data", "-E", "HOME=/var/www"}, cmd.Args...)
448 path, err := exec.LookPath("sudo")
450 return fmt.Errorf("LookPath(\"sudo\"): %w", err)
454 cmd.Stderr = super.Stderr
455 cmd.Env = super.environ
456 buf, err := cmd.Output() // /var/lib/arvados/.gem/ruby/2.5.0/bin:...
457 if err != nil || len(buf) == 0 {
458 return fmt.Errorf("gem env gempath: %w", err)
460 gempath := string(bytes.Split(buf, []byte{':'})[0])
461 super.prependEnv("PATH", gempath+"/bin:")
462 super.setEnv("GEM_HOME", gempath)
463 super.setEnv("GEM_PATH", gempath)
465 // Passenger install doesn't work unless $HOME is ~user
466 u, err := user.Current()
470 super.setEnv("HOME", u.HomeDir)
474 func (super *Supervisor) lookPath(prog string) string {
475 for _, val := range super.environ {
476 if strings.HasPrefix(val, "PATH=") {
477 for _, dir := range filepath.SplitList(val[5:]) {
478 path := filepath.Join(dir, prog)
479 if fi, err := os.Stat(path); err == nil && fi.Mode()&0111 != 0 {
488 type runOptions struct {
489 output io.Writer // attach stdout
490 env []string // add/replace environment variables
491 user string // run as specified user
495 // RunProgram runs prog with args, using dir as working directory. If ctx is
496 // cancelled while the child is running, RunProgram terminates the child, waits
497 // for it to exit, then returns.
499 // Child's environment will have our env vars, plus any given in env.
501 // Child's stdout will be written to output if non-nil, otherwise the
502 // boot command's stderr.
503 func (super *Supervisor) RunProgram(ctx context.Context, dir string, opts runOptions, prog string, args ...string) error {
504 cmdline := fmt.Sprintf("%s", append([]string{prog}, args...))
505 super.logger.WithField("command", cmdline).WithField("dir", dir).Info("executing")
510 if logprefix == "sudo" {
511 for i := 0; i < len(args); i++ {
514 } else if args[i] == "-E" || strings.Contains(args[i], "=") {
517 innerargs = args[i+1:]
522 logprefix = strings.TrimPrefix(logprefix, "/var/lib/arvados/bin/")
523 logprefix = strings.TrimPrefix(logprefix, super.tempdir+"/bin/")
524 if logprefix == "bundle" && len(innerargs) > 2 && innerargs[0] == "exec" {
525 _, dirbase := filepath.Split(dir)
526 logprefix = innerargs[1] + "@" + dirbase
527 } else if logprefix == "arvados-server" && len(args) > 1 {
530 if !strings.HasPrefix(dir, "/") {
531 logprefix = dir + ": " + logprefix
535 cmd := exec.Command(super.lookPath(prog), args...)
536 cmd.Stdin = opts.stdin
537 stdout, err := cmd.StdoutPipe()
541 stderr, err := cmd.StderrPipe()
545 logwriter := &service.LogPrefixer{Writer: super.Stderr, Prefix: []byte("[" + logprefix + "] ")}
546 var copiers sync.WaitGroup
549 io.Copy(logwriter, stderr)
554 if opts.output == nil {
555 io.Copy(logwriter, stdout)
557 io.Copy(opts.output, stdout)
562 if strings.HasPrefix(dir, "/") {
565 cmd.Dir = filepath.Join(super.SourcePath, dir)
567 env := append([]string(nil), opts.env...)
568 env = append(env, super.environ...)
569 cmd.Env = dedupEnv(env)
572 // Note: We use this approach instead of "sudo"
573 // because in certain circumstances (we are pid 1 in a
574 // docker container, and our passenger child process
575 // changes to pgid 1) the intermediate sudo process
576 // notices we have the same pgid as our child and
577 // refuses to propagate signals from us to our child,
578 // so we can't signal/shutdown our passenger/rails
579 // apps. "chpst" or "setuidgid" would work, but these
580 // few lines avoid depending on runit/daemontools.
581 u, err := user.Lookup(opts.user)
583 return fmt.Errorf("user.Lookup(%q): %w", opts.user, err)
585 uid, _ := strconv.Atoi(u.Uid)
586 gid, _ := strconv.Atoi(u.Gid)
587 cmd.SysProcAttr = &syscall.SysProcAttr{
588 Credential: &syscall.Credential{
596 defer func() { exited = true }()
599 log := ctxlog.FromContext(ctx).WithFields(logrus.Fields{"dir": dir, "cmdline": cmdline})
601 if cmd.Process == nil {
602 log.Debug("waiting for child process to start")
603 time.Sleep(time.Second / 2)
605 log.WithField("PID", cmd.Process.Pid).Debug("sending SIGTERM")
606 cmd.Process.Signal(syscall.SIGTERM)
607 time.Sleep(5 * time.Second)
611 log.WithField("PID", cmd.Process.Pid).Warn("still waiting for child process to exit 5s after SIGTERM")
623 if ctx.Err() != nil {
624 // Return "context canceled", instead of the "killed"
625 // error that was probably caused by the context being
628 } else if err != nil {
629 return fmt.Errorf("%s: error: %v", cmdline, err)
634 func (super *Supervisor) autofillConfig(cfg *arvados.Config) error {
635 cluster, err := cfg.GetCluster("")
639 usedPort := map[string]bool{}
640 nextPort := func(host string) (string, error) {
642 port, err := availablePort(host)
644 port, err = availablePort(super.ListenHost)
652 usedPort[port] = true
656 if cluster.Services.Controller.ExternalURL.Host == "" {
657 h, p, err := net.SplitHostPort(super.ControllerAddr)
659 return fmt.Errorf("SplitHostPort(ControllerAddr): %w", err)
670 cluster.Services.Controller.ExternalURL = arvados.URL{Scheme: "https", Host: net.JoinHostPort(h, p), Path: "/"}
672 u := url.URL(cluster.Services.Controller.ExternalURL)
673 defaultExtHost := u.Hostname()
674 for _, svc := range []*arvados.Service{
675 &cluster.Services.Controller,
676 &cluster.Services.DispatchCloud,
677 &cluster.Services.GitHTTP,
678 &cluster.Services.Health,
679 &cluster.Services.Keepproxy,
680 &cluster.Services.Keepstore,
681 &cluster.Services.RailsAPI,
682 &cluster.Services.WebDAV,
683 &cluster.Services.WebDAVDownload,
684 &cluster.Services.Websocket,
685 &cluster.Services.Workbench1,
686 &cluster.Services.Workbench2,
688 if svc == &cluster.Services.DispatchCloud && super.ClusterType == "test" {
691 if svc.ExternalURL.Host == "" {
692 port, err := nextPort(defaultExtHost)
696 host := net.JoinHostPort(defaultExtHost, port)
697 if svc == &cluster.Services.Controller ||
698 svc == &cluster.Services.GitHTTP ||
699 svc == &cluster.Services.Health ||
700 svc == &cluster.Services.Keepproxy ||
701 svc == &cluster.Services.WebDAV ||
702 svc == &cluster.Services.WebDAVDownload ||
703 svc == &cluster.Services.Workbench1 ||
704 svc == &cluster.Services.Workbench2 {
705 svc.ExternalURL = arvados.URL{Scheme: "https", Host: host, Path: "/"}
706 } else if svc == &cluster.Services.Websocket {
707 svc.ExternalURL = arvados.URL{Scheme: "wss", Host: host, Path: "/websocket"}
710 if super.NoWorkbench1 && svc == &cluster.Services.Workbench1 ||
711 super.NoWorkbench2 && svc == &cluster.Services.Workbench2 {
712 // When workbench1 is disabled, it gets an
713 // ExternalURL (so we have a valid listening
714 // port to write in our Nginx config) but no
715 // InternalURLs (so health checker doesn't
719 if len(svc.InternalURLs) == 0 {
720 port, err := nextPort(super.ListenHost)
724 host := net.JoinHostPort(super.ListenHost, port)
725 svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{
726 {Scheme: "http", Host: host, Path: "/"}: {},
730 if super.ClusterType != "production" {
731 if cluster.SystemRootToken == "" {
732 cluster.SystemRootToken = randomHexString(64)
734 if cluster.ManagementToken == "" {
735 cluster.ManagementToken = randomHexString(64)
737 if cluster.Collections.BlobSigningKey == "" {
738 cluster.Collections.BlobSigningKey = randomHexString(64)
740 if cluster.Users.AnonymousUserToken == "" {
741 cluster.Users.AnonymousUserToken = randomHexString(64)
743 if cluster.Containers.DispatchPrivateKey == "" {
744 buf, err := ioutil.ReadFile(filepath.Join(super.SourcePath, "lib", "dispatchcloud", "test", "sshkey_dispatch"))
748 cluster.Containers.DispatchPrivateKey = string(buf)
750 cluster.TLS.Insecure = true
752 if super.ClusterType == "test" {
753 // Add a second keepstore process.
754 port, err := nextPort(super.ListenHost)
758 host := net.JoinHostPort(super.ListenHost, port)
759 cluster.Services.Keepstore.InternalURLs[arvados.URL{Scheme: "http", Host: host, Path: "/"}] = arvados.ServiceInstance{}
761 // Create a directory-backed volume for each keepstore
763 cluster.Volumes = map[string]arvados.Volume{}
764 for url := range cluster.Services.Keepstore.InternalURLs {
765 volnum := len(cluster.Volumes)
766 datadir := fmt.Sprintf("%s/keep%d.data", super.tempdir, volnum)
767 if _, err = os.Stat(datadir + "/."); err == nil {
768 } else if !os.IsNotExist(err) {
770 } else if err = os.Mkdir(datadir, 0755); err != nil {
773 cluster.Volumes[fmt.Sprintf(cluster.ClusterID+"-nyw5e-%015d", volnum)] = arvados.Volume{
775 DriverParameters: json.RawMessage(fmt.Sprintf(`{"Root":%q}`, datadir)),
776 AccessViaHosts: map[arvados.URL]arvados.VolumeAccess{
779 StorageClasses: map[string]bool{
786 cluster.StorageClasses = map[string]arvados.StorageClassConfig{
787 "default": {Default: true},
792 if super.OwnTemporaryDatabase {
793 port, err := nextPort("localhost")
797 cluster.PostgreSQL.Connection = arvados.PostgreSQLConnection{
798 "client_encoding": "utf8",
801 "dbname": "arvados_test",
803 "password": "insecure_arvados_test",
807 cfg.Clusters[cluster.ClusterID] = *cluster
811 func addrIsLocal(addr string) (bool, error) {
812 listener, err := net.Listen("tcp", addr)
816 } else if strings.Contains(err.Error(), "cannot assign requested address") {
823 func randomHexString(chars int) string {
824 b := make([]byte, chars/2)
825 _, err := rand.Read(b)
829 return fmt.Sprintf("%x", b)
832 func internalPort(svc arvados.Service) (host, port string, err error) {
833 if len(svc.InternalURLs) > 1 {
834 return "", "", errors.New("internalPort() doesn't work with multiple InternalURLs")
836 for u := range svc.InternalURLs {
838 host, port = u.Hostname(), u.Port()
841 case u.Scheme == "https", u.Scheme == "ws":
848 return "", "", fmt.Errorf("service has no InternalURLs")
851 func externalPort(svc arvados.Service) (string, error) {
852 u := url.URL(svc.ExternalURL)
853 if p := u.Port(); p != "" {
855 } else if u.Scheme == "https" || u.Scheme == "wss" {
862 func availablePort(host string) (string, error) {
863 ln, err := net.Listen("tcp", net.JoinHostPort(host, "0"))
868 _, port, err := net.SplitHostPort(ln.Addr().String())
875 // Try to connect to addr until it works, then close ch. Give up if
877 func waitForConnect(ctx context.Context, addr string) error {
878 dialer := net.Dialer{Timeout: time.Second}
879 for ctx.Err() == nil {
880 conn, err := dialer.DialContext(ctx, "tcp", addr)
882 time.Sleep(time.Second / 10)
891 func copyConfig(cfg *arvados.Config) *arvados.Config {
894 err := json.NewEncoder(pw).Encode(cfg)
900 cfg2 := new(arvados.Config)
901 err := json.NewDecoder(pr).Decode(cfg2)
908 func watchConfig(ctx context.Context, logger logrus.FieldLogger, cfgPath string, prevcfg *arvados.Config, fn func()) {
909 watcher, err := fsnotify.NewWatcher()
911 logger.WithError(err).Error("fsnotify setup failed")
914 defer watcher.Close()
916 err = watcher.Add(cfgPath)
918 logger.WithError(err).Error("fsnotify watcher failed")
926 case err, ok := <-watcher.Errors:
930 logger.WithError(err).Warn("fsnotify watcher reported error")
931 case _, ok := <-watcher.Events:
935 for len(watcher.Events) > 0 {
938 loader := config.NewLoader(&bytes.Buffer{}, &logrus.Logger{Out: ioutil.Discard})
939 loader.Path = cfgPath
940 loader.SkipAPICalls = true
941 cfg, err := loader.Load()
943 logger.WithError(err).Warn("error reloading config file after change detected; ignoring new config for now")
944 } else if reflect.DeepEqual(cfg, prevcfg) {
945 logger.Debug("config file changed but is still DeepEqual to the existing config")
947 logger.Debug("config changed, notifying supervisor")