aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2025-07-27 17:14:27 +0200
committerThomas Voss <mail@thomasvoss.com> 2025-07-27 17:14:27 +0200
commit50bd8ef6d4f48a48f623564e6b63f346904e6421 (patch)
treee4385989b7a92bb484fdffb4c21ded4a9d9493f8 /src
parentc9b91a8bb1d9249c0617bfa52f0129a9d5d123c5 (diff)
Improve on debug mode
Diffstat (limited to 'src')
-rw-r--r--src/app.go16
-rw-r--r--src/templates.go6
2 files changed, 22 insertions, 0 deletions
diff --git a/src/app.go b/src/app.go
new file mode 100644
index 0000000..7b3d905
--- /dev/null
+++ b/src/app.go
@@ -0,0 +1,16 @@
+package app
+
+import (
+ "os"
+ "syscall"
+
+ "git.thomasvoss.com/euro-cash.eu/pkg/atexit"
+ . "git.thomasvoss.com/euro-cash.eu/pkg/try"
+)
+
+func Restart() {
+ path := Try2(os.Executable())
+ atexit.Exec()
+ Try(syscall.Exec(path, append([]string{path}, os.Args[1:]...),
+ os.Environ()))
+}
diff --git a/src/templates.go b/src/templates.go
index 20fcf79..353c755 100644
--- a/src/templates.go
+++ b/src/templates.go
@@ -46,6 +46,12 @@ func BuildTemplates(dir fs.FS, debugp bool) {
buildAndSetTemplate(dir, name)
if debugp {
go watch.FileFS(dir, name, func() {
+ defer func() {
+ if p := recover(); p != nil {
+ log.Print(p)
+ }
+ }()
+
buildAndSetTemplate(dir, name)
log.Printf("Template ā€˜%s’ updated\n", name)
})