save rpgoress, not working
This commit is contained in:
@ -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
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user