summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-12-27 12:45:21 +0100
committerxengineering <me@xengineering.eu>2023-12-27 13:05:05 +0100
commit8b60724f7532c22be991cf15e4495e61c8fc7287 (patch)
tree63035c850792af06259ecaf62b33bb7e8afc43fe
parent8ce328fafd9b2ad152f0afc16176cf01e1e66669 (diff)
downloadceres-8b60724f7532c22be991cf15e4495e61c8fc7287.tar
ceres-8b60724f7532c22be991cf15e4495e61c8fc7287.tar.zst
ceres-8b60724f7532c22be991cf15e4495e61c8fc7287.zip
Shutdown only on OS signal
This is the intended behaviour for production and also for debugging to at least inspect the data directory of Ceres.
-rw-r--r--main.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/main.go b/main.go
index cba4416..5665d86 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,11 @@
package main
import (
+ "log"
+ "os"
+ "os/signal"
+ "syscall"
+
"xengineering.eu/ceres/model"
)
@@ -10,4 +15,10 @@ func main() {
model.InitDatabase()
defer model.CloseDatabase()
+
+ listener := make(chan os.Signal)
+ signal.Notify(listener, syscall.SIGTERM)
+ signal.Notify(listener, syscall.SIGINT)
+ sig := <-listener
+ log.Printf("Cleaning up due to OS signal '%v'\n", sig)
}