Exemplo n.º 1
0
func (p *Poller) Run() {

	// Setup DocumentType
	if p.config.DocumentType == "" {
		p.config.DocumentType = DefaultDocumentType
	}

	//init the cron schedule
	if p.config.Cron != "" {
		p.cron = p.config.Cron
	} else {
		p.cron = DefaultCron
	}

	cron := cron.New()
	cron.AddFunc(p.config.Cron, func() { p.runOneTime() })
	cron.Start()
}
Exemplo n.º 2
0
func (e *Executor) Run() {

	// Setup DocumentType
	if e.config.DocumentType == "" {
		e.config.DocumentType = DefaultDocumentType
	}

	//init the cron schedule
	if e.config.Cron != "" {
		e.cron = e.config.Cron
	} else {
		e.cron = DefaultCron
	}

	cron := cron.New()
	cron.AddFunc(e.config.Cron, func() { e.runOneTime() })
	cron.Start()
}
Exemplo n.º 3
0
var index int
var totalDuration time.Duration
var wasWarned = false
var leewayExpired = false
var leewayMutex = new(sync.Mutex)
var suspendCount = 0
var suspendEnabled = false
var manualBlocked = false
var autoCloseCountdown = 0

var plugin *Plugin = &Plugin{
	Init: func(input chan ChromebusRecord, aggregator Aggregator) {
		log.Printf("Started Activity plugin")

		cron := cron.New()
		cron.AddFunc(resetCron, resetLeeway)
		//cron.AddFunc("0 */5 * * * *", resetLeeway) // 3pm every day
		cron.Start()
		initLeeway()
		go monitor()
	},
	Handle: func(w http.ResponseWriter, r *http.Request) {
		log.Printf(r.URL.Path)
		switch r.URL.Path {
		case "/" + string(ActivityTracker) + "/suspend":
			if leewayExpired {
				log.Printf("suspending...")
				leewayMutex.Lock()
				suspendEnabled = true
				suspendCount++
				leewayMutex.Unlock()