Move persistence stuff to own package
This commit is contained in:
parent
742fb2be58
commit
72f5a67989
6
main.go
6
main.go
|
@ -12,8 +12,8 @@ import (
|
||||||
|
|
||||||
"git.hamburg.ccc.de/ccchh/spaceapid/config"
|
"git.hamburg.ccc.de/ccchh/spaceapid/config"
|
||||||
"git.hamburg.ccc.de/ccchh/spaceapid/handlers"
|
"git.hamburg.ccc.de/ccchh/spaceapid/handlers"
|
||||||
|
"git.hamburg.ccc.de/ccchh/spaceapid/persistence"
|
||||||
"git.hamburg.ccc.de/ccchh/spaceapid/types"
|
"git.hamburg.ccc.de/ccchh/spaceapid/types"
|
||||||
"git.hamburg.ccc.de/ccchh/spaceapid/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -39,7 +39,7 @@ func main() {
|
||||||
conf := config.ParseConfiguration()
|
conf := config.ParseConfiguration()
|
||||||
|
|
||||||
// Merge old state if present
|
// Merge old state if present
|
||||||
util.MergeOldState(&conf.Response)
|
persistence.MergeOldState(&conf.Response)
|
||||||
|
|
||||||
// Register signal handler
|
// Register signal handler
|
||||||
sc := make(chan os.Signal, 1)
|
sc := make(chan os.Signal, 1)
|
||||||
|
@ -47,7 +47,7 @@ func main() {
|
||||||
go func(resp *types.SpaceAPIResponseV14) {
|
go func(resp *types.SpaceAPIResponseV14) {
|
||||||
<-sc
|
<-sc
|
||||||
log.Println("Saving state and shutting down...")
|
log.Println("Saving state and shutting down...")
|
||||||
util.SaveCurrentState(*resp)
|
persistence.SaveCurrentState(*resp)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}(&conf.Response)
|
}(&conf.Response)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package util
|
package persistence
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
|
@ -1,6 +1,6 @@
|
||||||
//go:build !linux
|
//go:build !linux
|
||||||
|
|
||||||
package util
|
package persistence
|
||||||
|
|
||||||
const (
|
const (
|
||||||
persistentStateDir = "./"
|
persistentStateDir = "./"
|
|
@ -1,4 +1,4 @@
|
||||||
package util
|
package persistence
|
||||||
|
|
||||||
const (
|
const (
|
||||||
persistentStateDir = "/var/lib/spaceapid/"
|
persistentStateDir = "/var/lib/spaceapid/"
|
Loading…
Reference in a new issue