// Close stops working and releases resources.
Close stops working and releases resources.
// Close stops working and releases resources .
func (w *SourceWorker) Stop(graceful bool) {
	if w.closed.Load() {
		w.l.Warn("already closed")
		return
	}
	w.cancel()
	w.wg.Wait()
	w.relayWg.Wait()
	w.subTaskWg.Wait()
	w.Lock()
	defer w.Unlock()
	if graceful {
		w.subTaskHolder.closeAllSubTasks()
	} else {
		w.subTaskHolder.killAllSubTasks()
	}
	if w.relayHolder != nil {
		w.relayHolder.Close()
	}
	if w.relayPurger != nil {
		w.relayPurger.Close()
	}
	if w.cfg.Checker.CheckEnable {
		w.taskStatusChecker.Close()
	}
	w.sourceDB.Close()
	w.sourceDB = nil
	w.closed.Store(true)
	w.l.Info("Stop worker")
}
func ( w * SourceWorker ) Stop ( graceful bool ) { if w . closed . Load ( ) { w . l . Warn ( " " ) return } w . cancel ( ) w . wg . Wait ( ) w . relayWg . Wait ( ) w . subTaskWg . Wait ( ) w . Lock ( ) defer w . Unlock ( ) if graceful { w . subTaskHolder . closeAllSubTasks ( ) } else { w . subTaskHolder . killAllSubTasks ( ) } if w . relayHolder != nil { w . relayHolder . Close ( ) } if w . relayPurger != nil { w . relayPurger . Close ( ) } if w . cfg . Checker . CheckEnable { w . taskStatusChecker . Close ( ) } w . sourceDB . Close ( ) w . sourceDB = nil w . closed . Store ( true ) w . l . Info ( " " ) }
Close stops working and releases resources.
Close stops working and releases resources .
// cancel status output ticker and wait for return // close or kill all subtasks // close task status checker