Skip to content

Instantly share code, notes, and snippets.

@izakp
Created Apr 9, 2014
Embed
What would you like to do?
diff --git a/cookbooks/sensu/files/default/run-cron.rb b/cookbooks/sensu/files/default/run-cron.rb
index bfd0455..b9f3e95 100644
--- a/cookbooks/sensu/files/default/run-cron.rb
+++ b/cookbooks/sensu/files/default/run-cron.rb
@@ -5,6 +5,7 @@ require 'shellwords'
require 'redis'
require 'time'
require 'yaml'
+require 'sentry-raven'
class RunRake < Sensu::Plugin::Check::CLI
option :task,
@@ -34,6 +35,19 @@ class RunRake < Sensu::Plugin::Check::CLI
@redis = Redis.new(:host => redis_config['host'], :port => redis_config['port'])
end
+ def exports
+ exports_file = "#{dir}/config/env.custom"
+ custom_exports = {}
+ if File.exists?(exports_file)
+ File.readlines(exports_file).each do |line|
+ if line.strip =~ /^export (.+)="(.+)"$/
+ custom_exports[$1] = $2
+ end
+ end
+ end
+ custom_exports
+ end
+
def env
config[:env]
end
@@ -52,6 +66,7 @@ class RunRake < Sensu::Plugin::Check::CLI
def run
env_hash = Hash[%w{RACK_ENV RAILS_ENV}.map { |var| [var, env] }]
+ env_hash.concat(exports)
cron_heartbeat_redis_key = "cron:heartbeat:#{env}:#{task}"
cmd = ['/usr/local/bin/bundle', 'exec', 'rake', task, '--trace']
cmd = Shellwords.join(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment