mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 13:29:05 +01:00
commit
981551e9c6
@ -327,6 +327,12 @@ func main() {
|
|||||||
api.MountRoutes(secured)
|
api.MountRoutes(secured)
|
||||||
|
|
||||||
if config.Keys.EmbedStaticFiles {
|
if config.Keys.EmbedStaticFiles {
|
||||||
|
if i, err := os.Stat("./var/img"); err == nil {
|
||||||
|
if i.IsDir() {
|
||||||
|
log.Info("Use local directory for static images")
|
||||||
|
r.PathPrefix("/img/").Handler(http.StripPrefix("/img/", http.FileServer(http.Dir("./var/img"))))
|
||||||
|
}
|
||||||
|
}
|
||||||
r.PathPrefix("/").Handler(web.ServeFiles())
|
r.PathPrefix("/").Handler(web.ServeFiles())
|
||||||
} else {
|
} else {
|
||||||
r.PathPrefix("/").Handler(http.FileServer(http.Dir(config.Keys.StaticFiles)))
|
r.PathPrefix("/").Handler(http.FileServer(http.Dir(config.Keys.StaticFiles)))
|
||||||
@ -395,14 +401,14 @@ func main() {
|
|||||||
// Because this program will want to bind to a privileged port (like 80), the listener must
|
// Because this program will want to bind to a privileged port (like 80), the listener must
|
||||||
// be established first, then the user can be changed, and after that,
|
// be established first, then the user can be changed, and after that,
|
||||||
// the actual http server can be started.
|
// the actual http server can be started.
|
||||||
if err := runtimeEnv.DropPrivileges(config.Keys.Group, config.Keys.User); err != nil {
|
if err = runtimeEnv.DropPrivileges(config.Keys.Group, config.Keys.User); err != nil {
|
||||||
log.Fatalf("error while preparing server start: %s", err.Error())
|
log.Fatalf("error while preparing server start: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := server.Serve(listener); err != nil && err != http.ErrServerClosed {
|
if err = server.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||||
log.Fatalf("starting server failed: %v", err)
|
log.Fatalf("starting server failed: %v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -428,7 +434,7 @@ func main() {
|
|||||||
log.Info("Register undead jobs service")
|
log.Info("Register undead jobs service")
|
||||||
|
|
||||||
s.Every(1).Day().At("3:00").Do(func() {
|
s.Every(1).Day().At("3:00").Do(func() {
|
||||||
err := jobRepo.StopJobsExceedingWalltimeBy(config.Keys.StopJobsExceedingWalltime)
|
err = jobRepo.StopJobsExceedingWalltimeBy(config.Keys.StopJobsExceedingWalltime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Error while looking for jobs exceeding their walltime: %s", err.Error())
|
log.Warnf("Error while looking for jobs exceeding their walltime: %s", err.Error())
|
||||||
}
|
}
|
||||||
@ -443,7 +449,7 @@ func main() {
|
|||||||
|
|
||||||
cfg.Retention.IncludeDB = true
|
cfg.Retention.IncludeDB = true
|
||||||
|
|
||||||
if err := json.Unmarshal(config.Keys.Archive, &cfg); err != nil {
|
if err = json.Unmarshal(config.Keys.Archive, &cfg); err != nil {
|
||||||
log.Warn("Error while unmarshaling raw config json")
|
log.Warn("Error while unmarshaling raw config json")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,14 @@ func init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if path == "templates/login.tmpl" {
|
||||||
|
if _, err := os.Stat("./var/login.tmpl"); err == nil {
|
||||||
|
log.Info("overwrite login.tmpl with local file")
|
||||||
|
templates[strings.TrimPrefix(path, "templates/")] =
|
||||||
|
template.Must(template.Must(base.Clone()).ParseFiles("./var/login.tmpl"))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
if path == "templates/imprint.tmpl" {
|
if path == "templates/imprint.tmpl" {
|
||||||
if _, err := os.Stat("./var/imprint.tmpl"); err == nil {
|
if _, err := os.Stat("./var/imprint.tmpl"); err == nil {
|
||||||
log.Info("overwrite imprint.tmpl with local file")
|
log.Info("overwrite imprint.tmpl with local file")
|
||||||
|
Loading…
Reference in New Issue
Block a user