save rpgoress, not working
This commit is contained in:
@ -21,6 +21,9 @@ type ConfigT struct {
|
|||||||
DatabaseConnStr string `json:"databaseConnStr"`
|
DatabaseConnStr string `json:"databaseConnStr"`
|
||||||
Attributes map[string]string `json:"attributes"`
|
Attributes map[string]string `json:"attributes"`
|
||||||
} `json:"handlers"`
|
} `json:"handlers"`
|
||||||
|
Archiver struct {
|
||||||
|
Dir string `json:"dir"`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var Config ConfigT
|
var Config ConfigT
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package dispatcher
|
package dispatcher
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
|
import "time"
|
||||||
|
import "os"
|
||||||
import "udi/mqtt"
|
import "udi/mqtt"
|
||||||
import "udi/config"
|
import "udi/config"
|
||||||
import "udi/handlers/handler"
|
import "udi/handlers/handler"
|
||||||
@ -26,9 +28,24 @@ func InitDispatcher() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func archiver() {
|
func archiver() {
|
||||||
|
archivingRootDir := config.Config.Archiver.Dir
|
||||||
|
currentArchivingDir := ""
|
||||||
|
lastArchivingDir := ""
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case _ = <- archiverChannel:
|
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")
|
log.Printf("Archiving message")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user