app/history/service.go

35 lines
752 B
Go
Raw Permalink Normal View History

2021-12-16 11:11:46 +00:00
package history
2021-12-16 13:43:56 +00:00
import (
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"kumoly.io/kumoly/app/store"
"kumoly.io/kumoly/app/system"
)
2021-12-16 11:11:46 +00:00
type Service struct {
system.BaseService
}
func (srv Service) GetName() string { return "history.Service" }
func (srv Service) IsService() bool { return true }
2021-12-16 13:43:56 +00:00
func (srv Service) Init() error {
PROD = viper.GetBool("prod")
l := log.With().Str("mod", "history").
Str("service", "history.Service").
Logger()
l.Debug().Msg("Migrating database for history.Service ...")
if err := store.Migrate(&History{}); err != nil {
l.Error().Err(err).Msg("Migrating database")
return err
}
return nil
}
2021-12-16 11:11:46 +00:00
func (srv Service) Main() error {
Start(DBReceiver)
return nil
}
func (srv Service) Del() {
Stop()
}