err := super.run(cfg)
if err != nil {
- fmt.Fprintln(super.Stderr, err)
+ super.logger.WithError(err).Warn("supervisor shut down")
}
close(super.done)
}()
return err
}
defer os.RemoveAll(super.tempdir)
- if err := os.Mkdir(filepath.Join(super.tempdir, "bin"), 0777); err != nil {
+ if err := os.Mkdir(filepath.Join(super.tempdir, "bin"), 0755); err != nil {
return err
}
// Fill in any missing config keys, and write the resulting
// config in the temp dir for child services to use.
- err = super.autofillConfig(cfg, super.logger)
+ err = super.autofillConfig(cfg)
if err != nil {
return err
}
- conffile, err := os.OpenFile(filepath.Join(super.tempdir, "config.yml"), os.O_CREATE|os.O_WRONLY, 0777)
+ conffile, err := os.OpenFile(filepath.Join(super.tempdir, "config.yml"), os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
return nil
}
-func (super *Supervisor) autofillConfig(cfg *arvados.Config, log logrus.FieldLogger) error {
+func (super *Supervisor) autofillConfig(cfg *arvados.Config) error {
cluster, err := cfg.GetCluster("")
if err != nil {
return err
}
usedPort := map[string]bool{}
- nextPort := func() string {
+ nextPort := func(host string) string {
for {
- port, err := availablePort(super.ListenHost)
+ port, err := availablePort(host)
if err != nil {
panic(err)
}
h = super.ListenHost
}
if p == "0" {
- p, err = availablePort(h)
- if err != nil {
- return err
- }
- usedPort[p] = true
+ p = nextPort(h)
}
cluster.Services.Controller.ExternalURL = arvados.URL{Scheme: "https", Host: net.JoinHostPort(h, p)}
}
svc == &cluster.Services.WebDAVDownload ||
svc == &cluster.Services.Websocket ||
svc == &cluster.Services.Workbench1) {
- svc.ExternalURL = arvados.URL{Scheme: "https", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort())}
+ svc.ExternalURL = arvados.URL{Scheme: "https", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort(super.ListenHost))}
}
if len(svc.InternalURLs) == 0 {
svc.InternalURLs = map[arvados.URL]arvados.ServiceInstance{
- arvados.URL{Scheme: "http", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort())}: arvados.ServiceInstance{},
+ arvados.URL{Scheme: "http", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort(super.ListenHost))}: arvados.ServiceInstance{},
}
}
}
}
if super.ClusterType == "test" {
// Add a second keepstore process.
- cluster.Services.Keepstore.InternalURLs[arvados.URL{Scheme: "http", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort())}] = arvados.ServiceInstance{}
+ cluster.Services.Keepstore.InternalURLs[arvados.URL{Scheme: "http", Host: fmt.Sprintf("%s:%s", super.ListenHost, nextPort(super.ListenHost))}] = arvados.ServiceInstance{}
// Create a directory-backed volume for each keepstore
// process.
if _, err = os.Stat(datadir + "/."); err == nil {
} else if !os.IsNotExist(err) {
return err
- } else if err = os.Mkdir(datadir, 0777); err != nil {
+ } else if err = os.Mkdir(datadir, 0755); err != nil {
return err
}
cluster.Volumes[fmt.Sprintf(cluster.ClusterID+"-nyw5e-%015d", volnum)] = arvados.Volume{
cluster.PostgreSQL.Connection = arvados.PostgreSQLConnection{
"client_encoding": "utf8",
"host": "localhost",
- "port": nextPort(),
+ "port": nextPort(super.ListenHost),
"dbname": "arvados_test",
"user": "arvados",
"password": "insecure_arvados_test",