diff options
-rw-r--r-- | app/models/track_mailer.rb | 13 | ||||
-rwxr-xr-x | script/alert-tracks | 8 |
2 files changed, 19 insertions, 2 deletions
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index 89a4f3cad..1b37709b9 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -101,6 +101,19 @@ class TrackMailer < ApplicationMailer user.no_xapian_reindex = true user.save! end + return true + end + + def self.alert_tracks_loop + # Run alert_tracks in an endless loop, sleeping when there is nothing to do + while true + sleep_seconds = 1 + while !alert_tracks + sleep sleep_seconds + sleep_seconds *= 2 + sleep_seconds = 300 if sleep_seconds > 300 + end + end end end diff --git a/script/alert-tracks b/script/alert-tracks index 056a88078..117f7a406 100755 --- a/script/alert-tracks +++ b/script/alert-tracks @@ -2,6 +2,10 @@ LOC=`dirname $0` -$LOC/runner 'TrackMailer.alert_tracks' - +if [ "$1" == "--loop" ] +then + "$LOC/runner" 'TrackMailer.alert_tracks_loop' +else + "$LOC/runner" 'TrackMailer.alert_tracks' +fi |