package cleanup
import (
"context"
"os"
"github.com/sirupsen/logrus"
)
type CleanupComponent struct {
cleanup *LocalFileCleanup
}
var defaultCleanupComponent *CleanupComponent
func New() *CleanupComponent {
defaultCleanupComponent = &CleanupComponent{}
return defaultCleanupComponent
}
func (c *CleanupComponent) Start(ctx context.Context) error {
dataPath := "/grdata"
if envPath := os.Getenv("GRDATA_PATH"); envPath != "" {
dataPath = envPath
}
logrus.Infof("Starting local file cleanup service with data path: %s", dataPath)
c.cleanup = NewLocalFileCleanup(dataPath)
return nil
}
func (c *CleanupComponent) CloseHandle() {
if c.cleanup != nil {
logrus.Info("Closing local file cleanup service...")
c.cleanup.Close()
}
}
func Default() *CleanupComponent {
return defaultCleanupComponent
}