Skip to content

Commit

Permalink
Fixed symbol vs string match bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gip committed Feb 7, 2012
1 parent 774263f commit 0d0e7a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 73 deletions.
66 changes: 0 additions & 66 deletions config/example/telework_config.rb

This file was deleted.

5 changes: 3 additions & 2 deletions lib/resque-telework/manager.rb
Expand Up @@ -7,8 +7,8 @@ class Manager


def initialize(cfg) def initialize(cfg)
@RUN_DAEMON= true @RUN_DAEMON= true
@HOST= cfg[:hostname] @HOST= cfg['hostname']
@SLEEP= cfg[:daemon_pooling_interval] @SLEEP= cfg['daemon_pooling_interval']
@WORKERS= {} @WORKERS= {}
@STOPPED= [] @STOPPED= []
end end
Expand Down Expand Up @@ -48,6 +48,7 @@ def start
send_status( 'Error', "Exit called in #{@HOST} daemon but workers are still running") unless @WORKERS.empty? send_status( 'Error', "Exit called in #{@HOST} daemon but workers are still running") unless @WORKERS.empty?
rescue Exception => e # Other exceptions rescue Exception => e # Other exceptions
send_status( 'Error', "Exception #{e.message}") 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") send_status( 'Error', "Exception should not be raised in the #{@HOST} daemon, please submit a bug report")
end end


Expand Down
10 changes: 5 additions & 5 deletions lib/tasks/telework.rake
Expand Up @@ -3,23 +3,23 @@ namespace :telework do
desc 'Register a new revision into Telework' desc 'Register a new revision into Telework'
task :register_revision => :environment do task :register_revision => :environment do
cfg= get_config cfg= get_config
host= cfg[:hostname] host= cfg['hostname']
cfg.delete(:hostname) cfg.delete('hostname')
TeleworkRedis.new.register_revision(host, cfg) TeleworkRedis.new.register_revision(host, cfg)
end end


desc 'Start a Telework daemon on this machine and returns' desc 'Start a Telework daemon on this machine and returns'
task :start_daemon => :environment do task :start_daemon => :environment do
cfg= get_config cfg= get_config
host= cfg[:hostname] host= cfg['hostname']
daemon= Resque::Plugins::Telework::Manager.new(cfg) daemon= Resque::Plugins::Telework::Manager.new(cfg)
if daemon.is_alive(host) if daemon.is_alive(host)
msg= "There is already a daemon running on #{host}" msg= "There is already a daemon running on #{host}"
daemon.send_status( 'Error', msg) daemon.send_status( 'Error', msg)
daemon.send_status( 'Error', "This daemon (PID #{Process.pid}) cannot be started and will terminare now") daemon.send_status( 'Error', "This daemon (PID #{Process.pid}) cannot be started and will terminare now")
return nil return nil
end end
logp= cfg[:daemon_log_path] logp= cfg['daemon_log_path']
logp||= "." logp||= "."
logf= "#{logp}/telework_daemon.log" logf= "#{logp}/telework_daemon.log"
lpid= "#{logp}/telework_daemon.pid" lpid= "#{logp}/telework_daemon.pid"
Expand All @@ -46,7 +46,7 @@ namespace :telework do


def get_config def get_config
# TODO: look into TELEWORK_CONFIG_FILE # 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) ActiveSupport::JSON.decode(open("telework_config.log", "r").read).merge(ch)
end end


Expand Down

0 comments on commit 0d0e7a8

Please sign in to comment.