This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some references which helped | |
# http://blog.salsify.com/engineering/delayed-jobs-callbacks-and-hooks-in-rails | |
# http://stackoverflow.com/a/16639849/109175 | |
# example plugin: https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/plugins/clear_locks.rb | |
module Delayed | |
module Plugins | |
class Bugsnag < Plugin | |
callbacks do |lifecycle| | |
lifecycle.around(:invoke_job) do |job, &block| | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Delayed | |
module Plugins | |
class LogErrors < Plugin | |
callbacks do |lifecycle| | |
lifecycle.around(:invoke_job) do |job, &block| | |
begin | |
block.call(job) | |
rescue Exception => error | |
Delayed::Worker.logger.error(error.message) | |
Delayed::Worker.logger.error(error.backtrace.join("\n")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./spec/support/rake_testing_support.rb | |
def invoke_rake_task_in_test(task_name) | |
require 'rake' | |
Rails.application.load_tasks if Rake.application.tasks.count < 10 | |
Rake::Task[task_name].reenable | |
Rake::Task[task_name].invoke | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Process: ruby [1079] | |
Path: /usr/bin/ruby | |
Identifier: ruby | |
Version: ??? (???) | |
Code Type: X86 (Native) | |
Parent Process: zsh [327] | |
Date/Time: 2009-05-13 14:26:58.435 +0100 | |
OS Version: Mac OS X 10.5.6 (9G55) | |
Report Version: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Process: ruby [4332] | |
Path: /usr/bin/ruby | |
Identifier: ruby | |
Version: ??? (???) | |
Code Type: X86 (Native) | |
Parent Process: zsh [327] | |
Date/Time: 2009-05-15 11:15:29.213 +0100 | |
OS Version: Mac OS X 10.5.6 (9G55) | |
Report Version: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ADD this to Rakefile and run it by issuing rake roles.to_json | |
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles")) | |
namespace :roles do | |
desc "Convert ruby roles from ruby to json, creating/overwriting json files." | |
task :to_json do | |
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file| | |
role = Chef::Role.new | |
role.from_file(rb_file) | |
json_file = rb_file.sub(/\.rb$/,'.json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# better to use a monkeypatch - see https://gist.github.com/867960 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CHEF_REPO = "../chef_repo" # path to chef repo, | |
# because Vagrantfile is normally in application repo, not in chef repo. | |
# see also https://gist.github.com/867960 for chef_solo patch | |
module Vagrant | |
module Provisioners | |
class ChefSolo | |
class Config | |
attr_accessor :data_bag_path | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# save this in the library folder of a cookbook | |
# (e.g. ./coookbooks/vagrant/library/chef_solo_patch.rb) | |
# see also https://gist.github.com/867958 for vagrant patch | |
# based on http://lists.opscode.com/sympa/arc/chef/2011-02/msg00000.html | |
if Chef::Config[:solo] | |
class Chef | |
module Mixin | |
module Language | |
def data_bag(bag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/data_bag_item.rb:95:in `raw_data=': Data Bag Items must have an id key in the hash! {"evq"=>"https://api.opscode.com/organizations/ima_evq/data/apps/evq"} (Chef::Exceptions::ValidationFailed) | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/data_bag_item.rb:147:in `from_hash' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/data_bag_item.rb:183:in `load' | |
from /var/chef/cache/cookbooks/django/libraries/app.rb:6:in `initialize' | |
from /var/chef/cache/cookbooks/django/definitions/install.rb:3:in `new' | |
from /var/chef/cache/cookbooks/django/definitions/install.rb:3:in `from_file' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `instance_eval' | |
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `method_missing' | |
from /var/chef/cache/cookbooks/django/definitions/install.rb:42:in `from_file' | |
from /usr/lib/ruby/gems/1.8/gems/chef |
OlderNewer