]> git.openstreetmap.org Git - rails.git/blobdiff - lib/daemons/gpx_import.rb
Validate passwords properly when creating an account. Fixes #419.
[rails.git] / lib / daemons / gpx_import.rb
index 015a2791648451ae0555ad8c1a2de53a9a2ae517..3b7fb02e2fb1bf52453eb907565bb0b478f45cc4 100755 (executable)
@@ -1,37 +1,28 @@
 #!/usr/bin/env ruby
 
 #You might want to change this
-ENV["RAILS_ENV"] ||= "development"
+#ENV["RAILS_ENV"] ||= "development"
 
 require File.dirname(__FILE__) + "/../../config/environment"
 
-$running = true;
-Signal.trap("TERM") do 
-  $running = false
-end
+terminated = false
+
+logger = ActiveRecord::Base.logger
 
-while($running) do
-  
+while(true) do
   ActiveRecord::Base.logger.info("GPX Import daemon wake @ #{Time.now}.")
 
-  traces = Trace.find(:all, :conditions => ['inserted = ?', false])
+  Trace.find(:all, :conditions => ['inserted = ?', false]).each do |trace|
+    Signal.trap("TERM") do 
+      terminated = true
+    end
 
-  if traces and traces.length > 0
-    traces.each do |trace|
-      begin
+    trace.import
 
-        ActiveRecord::Base.logger.info("GPX Import importing #{trace.name} from #{trace.user.email}")
+    Signal.trap("TERM", "DEFAULT")
 
-        #  gpx = OSM::GPXImporter.new('/tmp/2.gpx')
-        #  gpx.points do |point|
-        #    puts point['latitude']
-        #  end
-        
-        Notifier::deliver_gpx_success(trace)
-      rescue
-        Notifier::deliver_gpx_failure(trace)
-      end
-    end
+    exit if terminated
   end
+
   sleep 15.minutes
 end