save rpgoress, not working

This commit is contained in:
2023-11-28 10:23:21 +01:00
parent bf5e2c3a49
commit 3094cf9cd4
2 changed files with 20 additions and 0 deletions

View File

@ -21,6 +21,9 @@ type ConfigT struct {
DatabaseConnStr string `json:"databaseConnStr"`
Attributes map[string]string `json:"attributes"`
} `json:"handlers"`
Archiver struct {
Dir string `json:"dir"`
}
}
var Config ConfigT

View File

@ -1,6 +1,8 @@
package dispatcher
import "log"
import "time"
import "os"
import "udi/mqtt"
import "udi/config"
import "udi/handlers/handler"
@ -26,9 +28,24 @@ func InitDispatcher() {
}
func archiver() {
archivingRootDir := config.Config.Archiver.Dir
currentArchivingDir := ""
lastArchivingDir := ""
for {
select {
case _ = <- archiverChannel:
currentTime := time.Now()
currentDateStr := currentTime.Format("2006/01/02")
currentArchivingDir := archivingRootDir + "/" + currentDateStr
if currentArchivingDir != lastArchivingDir {
err := os.MkdirAll(currentArchivingDir, 0755)
if err := nil {
log.Printf("Unable to create archiving dir %s", currentArchivingDir)
}
lastArchivingDir = currentArchivingDir
}
archivingFilename := currentArchivingDir + "/" + string(currentTime.Hour()) + "/"
log.Printf("Archiving message")
}
}