-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interval between repository scans in now configurable
The default is 5 minutes, no restart is needed to change the value (ref #18)
- Loading branch information
Showing
5 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ func checkRedirect(req *http.Request, via []*http.Request) error { | |
// Main monitor loop | ||
func (m *Monitor) monitorLoop() { | ||
m.wg.Add(1) | ||
m.syncSource() | ||
m.scanRepository() | ||
|
||
mirrorUpdateEvent := make(chan string, 10) | ||
m.redis.pubsub.SubscribeEvent(MIRROR_UPDATE, mirrorUpdateEvent) | ||
|
@@ -144,8 +144,10 @@ func (m *Monitor) monitorLoop() { | |
} | ||
|
||
// Setup recurrent tasks | ||
sourceSyncTicker := time.NewTicker(5 * time.Minute) | ||
repositoryScanInterval := -1 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
etix
Author
Owner
|
||
repositoryScanTicker := time.NewTicker(1 * time.Minute) | ||
mirrorCheckTicker := time.NewTicker(1 * time.Second) | ||
configUpdateTicker := time.NewTicker(1 * time.Second) | ||
|
||
for { | ||
select { | ||
|
@@ -154,8 +156,18 @@ func (m *Monitor) monitorLoop() { | |
return | ||
case id := <-mirrorUpdateEvent: | ||
m.syncMirrorList(id) | ||
case <-sourceSyncTicker.C: | ||
m.syncSource() | ||
case <-configUpdateTicker.C: | ||
if repositoryScanInterval != GetConfig().RepositoryScanInterval { | ||
repositoryScanInterval = GetConfig().RepositoryScanInterval | ||
|
||
if repositoryScanInterval == 0 { | ||
repositoryScanTicker.Stop() | ||
} else { | ||
repositoryScanTicker = time.NewTicker(time.Duration(repositoryScanInterval) * time.Minute) | ||
} | ||
} | ||
case <-repositoryScanTicker.C: | ||
m.scanRepository() | ||
case <-mirrorCheckTicker.C: | ||
m.mapLock.Lock() | ||
for k, v := range m.mirrors { | ||
|
@@ -434,7 +446,7 @@ func (m *Monitor) getRandomFile(identifier string) (file string, size int64, err | |
} | ||
|
||
// Trigger a sync of the local repository | ||
func (m *Monitor) syncSource() { | ||
func (m *Monitor) scanRepository() { | ||
err := ScanSource(m.redis, m.stop) | ||
if err != nil { | ||
log.Error("Scanning source failed: %s", err.Error()) | ||
|
doesn't this mean the real default value is "disabled"? I.e when there is no setting in the config