From fcd37587f2a1343e59139926ef6c00d3fb04002c Mon Sep 17 00:00:00 2001 From: Steve Coast Date: Fri, 1 Dec 2006 12:06:38 +0000 Subject: [PATCH 1/1] add daemons --- README | 3 ++- config/daemons.yml | 5 +++++ lib/daemons/gpx_import.rb | 19 +++++++++++++++++++ lib/daemons/gpx_import_ctl | 15 +++++++++++++++ script/daemons | 2 ++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 config/daemons.yml create mode 100755 lib/daemons/gpx_import.rb create mode 100755 lib/daemons/gpx_import_ctl create mode 100755 script/daemons diff --git a/README b/README index c245579a1..b28b918fb 100644 --- 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 index 000000000..c9f78f583 --- /dev/null +++ b/config/daemons.yml @@ -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 index 000000000..c3cd9b06b --- /dev/null +++ b/lib/daemons/gpx_import.rb @@ -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 index 000000000..5730005a6 --- /dev/null +++ b/lib/daemons/gpx_import_ctl @@ -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 index 000000000..feb98b645 --- /dev/null +++ b/script/daemons @@ -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 -- 2.43.2