Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed symbol vs string match bug

  • Loading branch information...
commit 0d0e7a8241db550362135b08eddd029e4e13c382 1 parent 774263f
@gip authored
View
66 config/example/telework_config.rb
@@ -1,66 +0,0 @@
-# Configuration class for the resque-telework plugin
-
-# This is an example file that works with git and github
-# You may copy this file to your Rails config/initializers directory
-# and make changes to the TeleworkConfig class to reflect your environment
-
-# Note that this implementation is using git commands under the hood
-# Another way would be to have the deployement script generate a configuration
-# file (in JSON for instance) and have the TeleworkConfig class load it
-
-
-# Example Teleconfig class, change it to reflect you environment
-# This class should have two methods: config and host_config
-#
-class TeleworkConfig
-
- def git_repo
- "https://github.com/john/reputedly" # <<< Change this line to point to your own github repo
- end
-
- def log_path
- "#{Rails.root.to_s}/log" # <<< Change this to set a different path to worker log files
- end
-
- def daemon_log_path
- "#{Rails.root.to_s}/daemon_log" # <<< Change this to set a path to daemon log files
- end
-
- def daemon_pooling_interval
- 2 # <<< Change this to set a new daemon pooling interval (in seconds)
- end
-
- # Config method, works well for git
- def config
- revision= `git rev-parse HEAD`.chomp
- { :revision => revision,
- :revision_small => revision[0..6],
- :revision_path => Rails.root.to_s,
- :revision_link => "#{git_repo}/commit/#{revision}",
- :revision_branch => ( $1 if /\* (\S+)\s/.match(`git branch`) ),
- :revision_date => Time.parse(`git show --format=format:"%aD" | head -n1`),
- :revision_deployement_date => Time.now,
- :revision_info => `git log -1` }.merge(host_config)
- end
-
- def host_config
- { :hostname => find_hostname,
- :daemon_pooling_interval => daemon_pooling_interval,
- :daemon_log_path => daemon_log_path }
- end
-
- def find_hostname
- # To find the hostname, we successively looks into
- # 1) the environement variable TELEWORK_HOSTNAME
- # 2) we get it through a Socket call
- host= ENV['TELEWORK_HOSTNAME']
- unless host
- require 'socket'
- host= Socket::gethostname()
- end
- raise "Could not find hostname.. exiting" unless host
- host
- end
-
-end
-
View
5 lib/resque-telework/manager.rb
@@ -7,8 +7,8 @@ class Manager
def initialize(cfg)
@RUN_DAEMON= true
- @HOST= cfg[:hostname]
- @SLEEP= cfg[:daemon_pooling_interval]
+ @HOST= cfg['hostname']
+ @SLEEP= cfg['daemon_pooling_interval']
@WORKERS= {}
@STOPPED= []
end
@@ -48,6 +48,7 @@ def start
send_status( 'Error', "Exit called in #{@HOST} daemon but workers are still running") unless @WORKERS.empty?
rescue Exception => e # Other exceptions
send_status( 'Error', "Exception #{e.message}")
+ puts "Backtrace: #{e.backtrace}"
send_status( 'Error', "Exception should not be raised in the #{@HOST} daemon, please submit a bug report")
end
View
10 lib/tasks/telework.rake
@@ -3,15 +3,15 @@ namespace :telework do
desc 'Register a new revision into Telework'
task :register_revision => :environment do
cfg= get_config
- host= cfg[:hostname]
- cfg.delete(:hostname)
+ host= cfg['hostname']
+ cfg.delete('hostname')
TeleworkRedis.new.register_revision(host, cfg)
end
desc 'Start a Telework daemon on this machine and returns'
task :start_daemon => :environment do
cfg= get_config
- host= cfg[:hostname]
+ host= cfg['hostname']
daemon= Resque::Plugins::Telework::Manager.new(cfg)
if daemon.is_alive(host)
msg= "There is already a daemon running on #{host}"
@@ -19,7 +19,7 @@ namespace :telework do
daemon.send_status( 'Error', "This daemon (PID #{Process.pid}) cannot be started and will terminare now")
return nil
end
- logp= cfg[:daemon_log_path]
+ logp= cfg['daemon_log_path']
logp||= "."
logf= "#{logp}/telework_daemon.log"
lpid= "#{logp}/telework_daemon.pid"
@@ -46,7 +46,7 @@ namespace :telework do
def get_config
# TODO: look into TELEWORK_CONFIG_FILE
- ch= { :hostname => find_hostname }
+ ch= { 'hostname' => find_hostname }
ActiveSupport::JSON.decode(open("telework_config.log", "r").read).merge(ch)
end
Please sign in to comment.
Something went wrong with that request. Please try again.