aboutsummaryrefslogtreecommitdiffstats
path: root/modules/templates/htmlrenderer.go
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2023-05-22 17:51:40 +0200
committerGitHub <noreply@github.com>2023-05-22 23:51:40 +0800
commit3588edbb08f93aaa56defa82dffdbb202cd9aa4a (patch)
treead3b571f18534d3932642d3c069c495a31e9966c /modules/templates/htmlrenderer.go
parent922c83eea3407746a0472e5e3ad8b78a3136c661 (diff)
downloadgitea-3588edbb08f93aaa56defa82dffdbb202cd9aa4a.tar.gz
gitea-3588edbb08f93aaa56defa82dffdbb202cd9aa4a.zip
Add gitea manager reload-templates command (#24843)
This can be useful to update custom templates in production mode, when they are updated frequently and a full Gitea restart each time is disruptive.
Diffstat (limited to 'modules/templates/htmlrenderer.go')
-rw-r--r--modules/templates/htmlrenderer.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/templates/htmlrenderer.go b/modules/templates/htmlrenderer.go
index 311e5b741d..21c268da78 100644
--- a/modules/templates/htmlrenderer.go
+++ b/modules/templates/htmlrenderer.go
@@ -96,6 +96,14 @@ func HTMLRenderer() *HTMLRender {
return htmlRender
}
+func ReloadHTMLTemplates() error {
+ if err := htmlRender.CompileTemplates(); err != nil {
+ log.Error("Template error: %v\n%s", err, log.Stack(2))
+ return err
+ }
+ return nil
+}
+
func initHTMLRenderer() {
rendererType := "static"
if !setting.IsProd {
@@ -115,9 +123,7 @@ func initHTMLRenderer() {
if !setting.IsProd {
go AssetFS().WatchLocalChanges(graceful.GetManager().ShutdownContext(), func() {
- if err := htmlRender.CompileTemplates(); err != nil {
- log.Error("Template error: %v\n%s", err, log.Stack(2))
- }
+ _ = ReloadHTMLTemplates()
})
}
}