| Commit message (Expand) | Author | Age | Files | Lines |
* | Run python with flag "-O" by default | hut | 2010-05-10 | 1 | -1/+1 |
* | Fixed bug #65 by adding flag "--fail-if-run" | hut | 2010-04-26 | 1 | -1/+1 |
* | ranger.py: removed whitespace | hut | 2010-04-12 | 1 | -4/+0 |
* | reverted a part of 45cf5174. Allow "source ranger ranger" again | hut | 2010-04-01 | 1 | -8/+7 |
* | removed the cd-after-exit hack | hut | 2010-03-29 | 1 | -13/+8 |
* | ranger.__init__: don't implicitly import ranger.__main__ | hut | 2010-03-26 | 1 | -1/+1 |
* | Changed license to the GNU General Public License | hut | 2010-02-28 | 1 | -12/+14 |
* | ranger.py: fixed cd-after-exit with spaces in directory | hut | 2010-02-24 | 1 | -1/+1 |
* | ranger.py: removed unnecessary code | hut | 2010-02-15 | 1 | -1/+1 |
* | ranger.py: reverted cd-after-exit to the old way | hut | 2010-02-14 | 1 | -10/+1 |
* | ranger.py: more simple '--debug' flag check | hut | 2010-02-14 | 1 | -1/+1 |
* | ranger.py: improved handling of bad import | hut | 2010-01-26 | 1 | -1/+2 |
* | ranger.py: more fixes | hut | 2010-01-12 | 1 | -2/+2 |
* | ranger.py: cleanup/fix | hut | 2010-01-11 | 1 | -9/+8 |
* | fixed #31, cd-after-exit works even after pressing ^C | hut | 2010-01-11 | 1 | -1/+12 |
* | added license information | hut | 2010-01-08 | 1 | -3/+17 |
* | F1 key (inside console) for viewing information about the command | hut | 2009-12-29 | 1 | -1/+1 |
* | shorten comment in ranger.py | hut | 2009-12-26 | 1 | -11/+5 |
* | implemented OpenConsole | hut | 2009-12-25 | 1 | -2/+2 |
* | random updates | hut | 2009-12-25 | 1 | -3/+16 |
* | tons of stuff | hut | 2009-12-17 | 1 | -1/+1 |
* | merged main with __init__ | hut | 2009-12-12 | 1 | -1/+1 |
* | restructurations | hut | 2009-12-11 | 1 | -2/+4 |
* | changing implementation of options | hut | 2009-12-06 | 1 | -3/+6 |
* | structural improvements | hut | 2009-12-01 | 1 | -46/+9 |
* | random improvements | hut | 2009-11-29 | 1 | -2/+2)
// Functions and types in this file pertain
// to periodic, regular actions.
// This is a wrapper for a *time.Ticker
// that adds another channel. It's used
// to signal to the ticker goroutines
// that they should stop the tickers
// and exit.
type tick struct {
isDB bool
t *time.Ticker
exit chan bool
}
// Creates a new instance of a tick
func initTicker(db bool, interval time.Duration) *tick {
return &tick{
isDB: db,
t: time.NewTicker(interval),
exit: make(chan bool, 1),
}
}
// Sends the signal to stop the tickers
// and for their respective goroutines
// to exit.
func killTickers() {
ct := <-cTickC
dt := <-dbTickC
ct.exit <- true
dt.exit <- true
}
// Waits for a signal from the database
// *tick. Either stops the ticker and
// kills the goroutine or it will
// update cache / push the DB to disk
func dataTimer(tkr *tick) {
for {
select {
case signal := <-tkr.t.C:
if tkr.isDB {
errLog("", pushDB())
log.Printf("Database push took: %v\n", time.Since(signal))
continue
}
cacheUpdate()
log.Printf("Cache update took: %v\n", time.Since(signal))
case <-tkr.exit:
tkr.t.Stop()
return
}
}
}
// Called when a change is detected in the
// configuration file. Closes log file,
// closes database connection, stops all
// tickers, then binds new configuration
// values, opens new log file, connects to
// new database, and starts new cache and
// database tickers.
func reInit(e fsnotify.Event) {
log.Printf("%v. Reloading...\n", e.String())
if !confObj.StdoutLogging {
closeLog <- true
}
killTickers()
killDB()
bindConfig()
initLogging()
initDatabase()
initPersistence()
}
// Starts the tickers that periodically:
// - pull new user statuses into cache
// - push cached data to disk
func initPersistence() {
confObj.Mu.RLock()
cacheTkr := initTicker(false, confObj.CacheInterval)
dbTkr := initTicker(true, confObj.DBInterval)
confObj.Mu.RUnlock()
go dataTimer(cacheTkr)
go dataTimer(dbTkr)
dbTickC <- dbTkr
cTickC <- cacheTkr
}
|