]> git.openstreetmap.org Git - rails.git/commitdiff
add daemons
authorSteve Coast <steve@asklater.com>
Fri, 1 Dec 2006 12:06:38 +0000 (12:06 +0000)
committerSteve Coast <steve@asklater.com>
Fri, 1 Dec 2006 12:06:38 +0000 (12:06 +0000)
README
config/daemons.yml [new file with mode: 0644]
lib/daemons/gpx_import.rb [new file with mode: 0755]
lib/daemons/gpx_import_ctl [new file with mode: 0755]
script/daemons [new file with mode: 0755]

diff --git a/README b/README
index c245579a14307fdb54c7d06603c23a5ba3e6b0d1..b28b918fb489adbb431eb1e9d89b7e3cfa1103fa 100644 (file)
--- a/README
+++ b/README
@@ -35,4 +35,5 @@ Lots of tests are needed to test the API.
 
 Lots of little things to make the site work like the old one.
 
-Also see the 'rails_port' component for bugs on trac.openstreetmap.org
+Also see the 'rails_port' component for bugs:
+http://trac.openstreetmap.org/query?status=new&status=assigned&status=reopened&component=rails_port&order=priority
diff --git a/config/daemons.yml b/config/daemons.yml
new file mode 100644 (file)
index 0000000..c9f78f5
--- /dev/null
@@ -0,0 +1,5 @@
+dir_mode: script
+dir: ../../log
+multiple: false
+backtrace: true
+monitor: true
\ No newline at end of file
diff --git a/lib/daemons/gpx_import.rb b/lib/daemons/gpx_import.rb
new file mode 100755 (executable)
index 0000000..c3cd9b0
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+#You might want to change this
+ENV["RAILS_ENV"] ||= "production"
+
+require File.dirname(__FILE__) + "/../../config/environment"
+
+$running = true;
+Signal.trap("TERM") do 
+  $running = false
+end
+
+while($running) do
+  
+  # Replace this with your code
+  ActiveRecord::Base.logger << "This daemon is still running at #{Time.now}.\n"
+  
+  sleep 10
+end
\ No newline at end of file
diff --git a/lib/daemons/gpx_import_ctl b/lib/daemons/gpx_import_ctl
new file mode 100755 (executable)
index 0000000..5730005
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+require 'rubygems'
+require "daemons"
+require 'yaml'
+require 'erb'
+require 'active_support'
+
+options = YAML.load(
+  ERB.new(
+  IO.read(
+  File.dirname(__FILE__) + "/../../config/daemons.yml"
+  )).result).with_indifferent_access
+options[:dir_mode] = options[:dir_mode].to_sym
+
+Daemons.run File.dirname(__FILE__) + '/gpx_import.rb', options
\ No newline at end of file
diff --git a/script/daemons b/script/daemons
new file mode 100755 (executable)
index 0000000..feb98b6
--- /dev/null
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+Dir[File.dirname(__FILE__) + "/../lib/daemons/*_ctl"].each {|f| `#{f} #{ARGV.first}`}
\ No newline at end of file