Add support for disabling the on-disk archive for pods with limited disk resources

fix_register_spam
James Mills 1 month ago
parent 1c597e5847
commit 5bbf89d422
Signed by: prologic
GPG Key ID: AC4C014F1440EBD6
  1. 9
      cmd/yarnd/main.go
  2. 1
      internal/config.go
  3. 11
      internal/options.go
  4. 15
      internal/server.go

@ -87,6 +87,7 @@ var (
disableLogger bool
disableMedia bool
disableFfmpeg bool
disableArchive bool
// Pod Limits
twtsPerPage int
@ -125,7 +126,7 @@ var (
enabledFeatures flagSliceOfFeatureType
)
func init() {
func initFlags() {
flag.BoolVarP(&debug, "debug", "D", false, "enable debug logging")
flag.StringVarP(&bind, "bind", "b", "0.0.0.0:8000", "[int]:<port> to bind to")
flag.BoolVarP(&version, "version", "v", false, "display version information")
@ -174,6 +175,10 @@ func init() {
&disableFfmpeg, "disable-ffmpeg", internal.DefaultDisableFfmpeg,
"whether or not to disable ffmpeg support for video and audio",
)
flag.BoolVar(
&disableArchive, "disable-archive", internal.DefaultDisableArchive,
"whether or not to disable the on-disk archive",
)
// Pod Limits
flag.IntVarP(
@ -301,6 +306,7 @@ func extraServiceInfoFactory(svr *internal.Server) profiler.ExtraServiceInfoRetr
}
func main() {
initFlags()
parseArgs()
if version {
@ -346,6 +352,7 @@ func main() {
internal.WithDisableLogger(disableLogger),
internal.WithDisableMedia(disableMedia),
internal.WithDisableFfmpeg(disableFfmpeg),
internal.WithDisableArchive(disableArchive),
// Pod Limits
internal.WithTwtsPerPage(twtsPerPage),

@ -141,6 +141,7 @@ type Config struct {
DisableLogger bool
DisableMedia bool
DisableFfmpeg bool
DisableArchive bool
SessionExpiry time.Duration
SessionCacheTTL time.Duration
TranscoderTimeout time.Duration

@ -79,6 +79,9 @@ const (
// DefaultDisableFfmpeg is the default for disabling ffmpeg support
DefaultDisableFfmpeg = false
// DefaultDisableArchive is the default for disabling on-disk archive support
DefaultDisableArchive = false
// DefaultCookieSecret is the server's default cookie secret
DefaultCookieSecret = InvalidConfigValue
@ -432,6 +435,14 @@ func WithDisableFfmpeg(disableFfmpeg bool) Option {
}
}
// WithDisableArchive sets the disable archive flag
func WithDisableArchive(disableArchive bool) Option {
return func(cfg *Config) error {
cfg.DisableArchive = disableArchive
return nil
}
}
// WithCookieSecret sets the server's cookie secret
func WithCookieSecret(secret string) Option {
return func(cfg *Config) error {

@ -972,10 +972,16 @@ func NewServer(bind string, options ...Option) (*Server, error) {
}
log.Debugf("After Cache: %s", MemoryUsage())
archive, err := NewDiskArchiver(filepath.Join(config.Data, archiveDir))
if err != nil {
log.WithError(err).Error("error creating feed archiver")
return nil, err
var archive Archiver
if !config.DisableArchive {
archive, err = NewDiskArchiver(filepath.Join(config.Data, archiveDir))
if err != nil {
log.WithError(err).Error("error creating feed archiver")
return nil, err
}
} else {
archive, _ = NewNullArchiver()
}
db, err := NewStore(config.Store)
@ -1138,6 +1144,7 @@ func NewServer(bind string, options ...Option) (*Server, error) {
log.Infof("Disable Logger: %t", server.config.DisableLogger)
log.Infof("Disable Media: %t", server.config.DisableMedia)
log.Infof("Disable FFMpeg: %t", server.config.DisableFfmpeg)
log.Infof("Disable Archive: %t", server.config.DisableArchive)
log.Infof("SMTP Host: %s", server.config.SMTPHost)
log.Infof("SMTP Port: %d", server.config.SMTPPort)
log.Infof("SMTP User: %s", server.config.SMTPUser)

Loading…
Cancel
Save