示例#1
0
文件: daemon.go 项目: hobeone/rss2go
// NewDaemon returns a pointer to a new Daemon struct with defaults set.
func NewDaemon(cfg *config.Config) *Daemon {
	var dbh *db.Handle
	logger := logrus.New()
	log.SetupLogger(logger)
	if *debugdb {
		logger.Level = logrus.DebugLevel
	}
	if cfg.DB.Type == "memory" {
		dbh = db.NewMemoryDBHandle(logger, false)
	} else {
		dbh = db.NewDBHandle(cfg.DB.Path, logger)
	}
	cc := make(chan *feedwatcher.FeedCrawlRequest, 1)
	rc := make(chan *feedwatcher.FeedCrawlResponse)
	mc := mail.CreateAndStartMailer(cfg).OutgoingMail

	return &Daemon{
		Config:    cfg,
		CrawlChan: cc,
		RespChan:  rc,
		MailChan:  mc,
		DBH:       dbh,
		Feeds:     make(map[string]*feedwatcher.FeedWatcher),
		PollFeeds: true,
		Logger:    logger,
	}
}
示例#2
0
文件: base.go 项目: hobeone/rss2go
func commonInit() (*config.Config, *db.Handle) {
	if *debug {
		logrus.SetLevel(logrus.DebugLevel)
	}
	cfg := loadConfig(*configfile)
	logger := logrus.New()
	log.SetupLogger(logger)
	if *debugdb {
		logger.Level = logrus.DebugLevel
	}

	dbh := db.NewDBHandle(cfg.DB.Path, logger)

	return cfg, dbh
}
示例#3
0
文件: main.go 项目: hobeone/rss2go
func main() {
	log.SetupLogger(logrus.StandardLogger())
	commands.RegisterCommands()
	kingpin.MustParse(commands.App.Parse(os.Args[1:]))
}