I am trying to convert an uploaded video into multiple formats but I am getting an error
Video model:
class Video < ActiveRecord::Base
has_attached_file :video, {
preserve_files: true,
styles: {
ogg: { :processors => [:ogg_processor] },
},
url: '/tmp/paperclip/:rails_env/video/:style/:filename',
path: ':rails_root/public:url',
}
# paperclip:
validates :video, attachment_presence: true
validates_with AttachmentContentTypeValidator, attributes: :video, content_type: /\Avideo\/.*\Z/
validates_with AttachmentSizeValidator, attributes: :video, less_than: 150.megabytes
end
This variation of options didn't work either:
has_attached_file :video, {
preserve_files: true,
processors: [:ogg_processor],
styles: {
original: {},
},
url: '/tmp/paperclip/:rails_env/video/:style/:filename',
path: ':rails_root/public:url',
}
Processor:
# lib/paperclip_processors/ogg_processor.rb
module Paperclip
class OggProcessor < Processor
def make
output = Tempfile.new([File.basename(#file.path), '.ogv'])
parameters = '--max_size 1280x1280 --output :output :input'
Paperclip.run('ffmpeg2theora', parameters, output: File.expand_path(file.path), input: File.expand_path(output.path))
output
end
end
end
Error:
Paperclip::AdapterRegistry::NoHandlerError: No handler found for "public/tmp/videos/SampleVideo_720x480_30mb.mkv"
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/io_adapters/registry.rb:19:in `handler_for'
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/io_adapters/registry.rb:29:in `for'
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/attachment.rb:98:in `assign'
/home/vedant/.gem/ruby/2.2.4/gems/paperclip-4.3.7/lib/paperclip/has_attached_file.rb:66:in `block in define_setter'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:54:in `public_send'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:35:in `each'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/core.rb:566:in `init_attributes'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/core.rb:281:in `initialize'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/inheritance.rb:61:in `new'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/inheritance.rb:61:in `new'
/home/vedant/.gem/ruby/2.2.4/gems/activerecord-4.2.5/lib/active_record/persistence.rb:50:in `create!'
/home/vedant/web/voggle/lib/tasks/dummy.rake:47:in `block (3 levels) in <top (required)>'
/home/vedant/web/voggle/lib/tasks/dummy.rake:46:in `each'
/home/vedant/web/voggle/lib/tasks/dummy.rake:46:in `block (2 levels) in <top (required)>'
/home/vedant/.gem/ruby/2.2.4/gems/airbrake-5.5.0/lib/airbrake/rake/task_ext.rb:19:in `execute'
/home/vedant/.gem/ruby/2.2.4/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => dummy:videos
(See full trace by running task with --trace)
Okay it was a very silly mistake.
I was sending a String instead of a File object. I just did File.new(video_file) and it worked.
Related
I have used whenever gems,where i have schedule more than 500 mails to execute at a particular time,but its not going.But if i send 15 or 20 email then it goes.I am getting the following in my output file of whenever.
rake aborted!
Net::SMTPServerBusy: 452 4.5.3 Error: too many recipients
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:114:in `block in deliver!'
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:113:in `deliver!'
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/mail-2.6.4/lib/mail/message.rb:253:in `deliver!'
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/actionmailer-4.2.4/lib/action_mailer/message_delivery.rb:77:in `deliver_now!'
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/actionmailer-4.2.4/lib/action_mailer/message_delivery.rb:95:in `deliver!'
/home/indiba3/hrms/lib/tasks/email_tasks.rake:25:in `block (2 levels) in <top (required)>'
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/indiba3/.rvm/gems/ruby-2.1.8/bin/ruby_executable_hooks:15:in `eval'
/home/indiba3/.rvm/gems/ruby-2.1.8/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => task_namespace:birthday_invitation_mail
(See full trace by running task with --trace)
So how may i slove this error and let the email to be sent to 500 person and if any email is wrong i may get the output in another log file........so pls help...........??
Fetch users in batches and then try to send mails.
mailer
def birthday_email
date = Date.today
Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')).where("age > 21").find_in_batches do |group|
sleep(5)
group.each { |emp| mail(to: emp.email, subject: 'Birthday Wishes') }
end
end
rake
EmployeeMailer.birthday_email.deliver!
I'm doing a test for receiving emails with Mailman gem in Rails4.2.1 (Ruby 2.1.6).
Receiving email is good, but I can't insert the data to a table with strong parameters.
There, the exception error seems to occur by the error
"...ERROR -- : private method `require' called for
#<ActiveSupport::HashWithIndifferentAccess:..."
I'd like to insert data with strong parameters after receiving email by using mailman gem.
Mailman gem provides Matcher referred to a params, so it may affect such problem.
Do I have something wrong ?
How can I use the strong parameters in mailman receiver ?
Thank you in advance.
My codes are as follows: mailman_server.rb
require 'rubygems'
require 'bundler/setup'
require 'mailman'
Mailman.config.poll_interval = 10
Mailman.config.pop3 = {
server: 'pop.sample.com',
username: 'test#sample.com',
password: 'password',
port: 110,
ssl: false
}
Mailman::Application.run do
to "%event%#sample.com" do
begin
UserMailer.receive(message)
params[:message] = {}
params[:message][:title] = message.subject
params[:message][:description] = message.text_part.body.decoded
#message = Message.new(params.require(:message).permit(:title, :description))
if #message.save
puts 'Message was successfully created.'
end
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:n#{message}"
Mailman.logger.error [e, *e.backtrace].join("n")
end
end
end
And user_mailer.rb:
class UserMailer < ApplicationMailer
def receive(message)
end
end
I tried another method, but got the following similar error.
E, [2015-09-15T15:29:26.944316 #2316] ERROR -- : Error encountered processing message: #<Net::POPMail 1>
NoMethodError: private method `require' called for #<ActiveSupport::HashWithIndifferentAccess:0x4523cb8>
C:/Users/gworth-sny/Z_userfolder/rails/mailman_model/app/controllers/messages_rec.rb:10:in `receive'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/router.rb:58:in `route'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/message_processor.rb:23:in `block in process'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/middleware.rb:33:in `call'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/middleware.rb:33:in `block in run'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/middleware.rb:38:in `call'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/middleware.rb:38:in `run'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/message_processor.rb:22:in `process'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/receiver/pop3.rb:49:in `block in get_messages'
C:/Ruby21/lib/ruby/2.1.0/net/pop.rb:665:in `each'
C:/Ruby21/lib/ruby/2.1.0/net/pop.rb:665:in `each_mail'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/receiver/pop3.rb:47:in `get_messages'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/application.rb:140:in `block in polling_loop'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/application.rb:137:in `loop'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/application.rb:137:in `polling_loop'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/application.rb:87:in `run'
C:/Ruby21/lib/ruby/gems/2.1.0/gems/mailman-0.7.3/lib/mailman/application.rb:15:in `run'
script/mailman_server.rb:19:in `<main>'
The codes that I changed are as follows.
Mailman::Application.run do
to "%event%#sample.com", "MessagesRec#receive" do
begin
rescue Exception => e
Mailman.logger.error "Exception occurred while receiving message:n#{message}"
Mailman.logger.error [e, *e.backtrace].join("n")
end
end
end
messages_rec.rb
class MessagesRec < ApplicationController
def receive(message, params)
puts "------------ #{message}"
params[:message] = {}
params[:message][:title] = message.subject
params[:message][:description] = message.text_part.body.decoded
puts "------------ #{params}"
#message = Message.new(params.require(:message).permit(:title, :description))
if #message.save
puts 'Message was successfully created.'
else
puts 'Message was lost.'
end
end
end
Does this error "NoMethodError: private method `require' called " mean that can not use in this mailman process ?
How is it possible ?
Thank you in advance.
I can't understand why bullect gem is complaining about n+1 queries when I actually included it in my query
Issue
N+1 Query detected
AddonTypeValue => [:addon_option_values]
Add to your finder: :includes => [:addon_option_values]
Query
addon_types = AddonType.includes(addon_type_values:
[addon_option_values: :addon_option_type]).
where(addon_type_values: {published: true, design_id: self.id}).
where{addon_type.addon_type_values.visible_for != not_for}
My view - jbuilder
json.addon_option_values addon_type_value.addon_option_values do |aov|
json.id aov.id
json.p_name aov.p_name
json.position aov.position
end
Request Output Log - N+1 Query method call stack
/app/views/api/v1/designs/show.json.jbuilder:45:in `block (2 levels) in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:39:in `block in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:35:in `_app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:45:in `block (2 levels) in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:39:in `block in _app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
/app/views/api/v1/designs/show.json.jbuilder:35:in `_app_views_api_v__designs_show_json_jbuilder___3899644929766612648_11335760'
I have a Classified Model where i use a after_create callback for checking keywords of a user and send email notification.
this email it is send by a Background Job using ActiveJobs and Sucker_punch as background driver.
I see in the logs 3 jobs are being queued:
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 8843b126-18fe-4cc1-b2f3-41141a199bcb) to SuckerPunch(mailers) with arguments: "NotificationMailer", "keyword_found", "deliver_now", gid://clasificados/Classified/233, gid://clasificados/User/1
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 591ce6eb-34d1-4381-93ea-4b708171996f) to SuckerPunch(mailers) with arguments: "NotificationMailer", "keyword_found", "deliver_now", gid://clasificados/Classified/234, gid://clasificados/User/1
[ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 3b1de0ea-f48d-41f2-be5a-8f5b2369b8ea) to SuckerPunch(mailers) with arguments: "NotificationMailer", "keyword_found", "deliver_now", gid://clasificados/Classified/235, gid://clasificados/User/1
but i only received 2 emails...
i see in logs errors like:
Terminating 6 actors...
Terminating task: type=:finalizer, meta={:method_name=>:__shutdown__}, status=:receiving
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.`
Terminating task: type=:call, meta={:method_name=>:perform}, status=:callwait
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
Celluloid::PoolManager: async call `perform` aborted!
Celluloid::Task::TerminatedError: task was terminated
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:34:in `terminate'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `each'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `cleanup'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:329:in `shutdown'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:164:in `run'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:130:in `block in start'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/thread_handle.rb:13:in `block in initialize'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor_system.rb:32:in `block in get_thread'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `call'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `block in create'
Terminating task: type=:call, meta={:method_name=>:perform}, status=:callwait
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
Celluloid::PoolManager: async call `perform` aborted!
Celluloid::Task::TerminatedError: task was terminated
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:34:in `terminate'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `each'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `cleanup'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:329:in `shutdown'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:164:in `run'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor.rb:130:in `block in start'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/thread_handle.rb:13:in `block in initialize'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/actor_system.rb:32:in `block in get_thread'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `call'
/home/angel/.gem/ruby/2.2.2/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `block in create'
Terminating task: type=:finalizer, meta={:method_name=>:__shutdown__}, status=:receiving
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
Model:
class Classified < ActiveRecord::Base
after_create :find_matched_keywords
def find_matched_keywords
User.all.each do |u|
u.profile.keywords.scan(/[a-zA-Z\d]+/) do |k|
if self[:content].downcase.include?(k)
SendEmailJob.new.async.perform(self, u)
break
end
end
end
end
end
Job:
class SendEmailJob < ActiveJob::Base
include SuckerPunch::Job
queue_as :default
def perform(classified, user)
NotificationMailer.keyword_found(classified, user).deliver_later
end
end
any idea what could be happening?
thanks in advance :D
well, i changed to sidekiq...
problem solved.
I am using the jenkins cookbook to set up a windows slave on AWS. Locally (vagrant on virtualbox), it converges correctly, but when provisioning a new machine on aws using chef-provisioning and the fog driver, I run into the following error:
================================================================================
Error executing action `create` on resource 'jenkins_windows_slave[build-slave]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "java" -jar "C:\chef\cache/jenkins-cli.jar" -s http://10.0.0.5:8080 groovy C:/Users/ADMINI~1/AppData/Local/Temp/groovy20150312-536-1d2hoy4 ----
STDOUT: Error occurred during initialization of VM
Unable to allocate 61440KB bitmaps for parallel garbage collection for the requested 1966080KB heap.
STDERR: Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
---- End output of "java" -jar "C:\chef\cache/jenkins-cli.jar" -s http://10.0.0.5:8080 groovyC:/Users/ADMINI~1/AppData/Local/Temp/groovy20150312-536-1d2hoy4 ----
Ran "java" -jar "C:\chef\cache/jenkins-cli.jar" -s http://10.0.0.5:8080 groovy C:/Users/ADMINI~1/AppData/Local/Temp/groovy20150312-536-1d2hoy4 returned 1
Resource Declaration:
---------------------
# In C:/chef/cache/cookbooks/xyz_jenkins/recipes/slave_windows.rb
53: jenkins_windows_slave node['jenkins']['node']['name'] do
54: remote_fs node['jenkins']['node']['remote_fs'] # jenkins workspace items stored here
55: group node['jenkins']['node']['group'] # Group with access to remote_fs
56: user node['jenkins']['node']['user'] # user the service runs under (and remote_fs owner)
57: password node['jenkins']['node']['password'] # for user running the service
58: labels node['jenkins']['node']['labels'] # labels on Jenkins master
59: action :create
60: end
Compiled Resource:
------------------
# Declared in C:/chef/cache/cookbooks/xyz_jenkins/recipes/slave_windows.rb:53:in `from_file'
jenkins_windows_slave("build-slave") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :jenkins_windows_slave
cookbook_name "xyz_jenkins"
recipe_name "slave_windows"
remote_fs "C:\\jenkins"
group "Everyone"
user "jenkins"
password "apasswordhere"
labels ["builder", "windows"]
slave_name "build-slave"
end
chef-provisioning's stack trace:
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/transport/winrm.rb:144:in `error!'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/machine/basic_machine.rb:31:in `block in execute'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `call'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `add_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider.rb:180:in `converge_by'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/chef_provider_action_handler.rb:54:in `perform_action'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/machine/basic_machine.rb:29:in `execute'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/convergence_strategy/install_msi.rb:49:in`block (2 levels) in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/run_context.rb:268:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/chef_provider_action_handler.rb:59:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/convergence_strategy/install_msi.rb:46:in`block in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/run_context.rb:268:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/chef_provider_action_handler.rb:59:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/convergence_strategy/install_msi.rb:45:in`converge'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/machine/basic_machine.rb:21:in `converge'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provider/machine.rb:62:in `block in <class:Machine>'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:in `block in action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider.rb:145:in `run_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource.rb:582:in `run_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:315:in `converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:400:in `block in run'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:399:in `catch'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:399:in `run'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:243:in `run_with_graceful_exit_option'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:220:in `block in run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:201:in `run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:355:in `block in interval_run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:345:in `loop'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:345:in `interval_run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:335:in `run_application'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:58:in `run'
C:/opscode/chefdk/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
C:/opscode/chefdk/bin/chef-client:52:in `load'
C:/opscode/chefdk/bin/chef-client:52:in `<main>'
chef run stack trace
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.1-x86-mingw32/lib/mixlib/shellout.rb:278:in `invalid!'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.1-x86-mingw32/lib/mixlib/shellout.rb:265:in `error!'
C:/chef/cache/cookbooks/jenkins/libraries/_executor.rb:82:in `execute!'
C:/chef/cache/cookbooks/jenkins/libraries/_executor.rb:127:in `groovy!'
C:/chef/cache/cookbooks/jenkins/libraries/slave.rb:315:in `current_slave'
C:/chef/cache/cookbooks/jenkins/libraries/slave.rb:129:in `load_current_resource'
C:/chef/cache/cookbooks/jenkins/libraries/slave_jnlp.rb:52:in `load_current_resource'
C:/chef/cache/cookbooks/jenkins/libraries/slave_windows.rb:62:in `load_current_resource'
C:/opscode/chef/embedded/apps/chef/lib/chef/provider.rb:128:in `run_action'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource.rb:561:in `run_action'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:331:in `block in converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:326:in `catch'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:326:in `converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:345:in `converge_and_save'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:448:in `run'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:253:in `run_with_graceful_exit_option'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:230:in `block in run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `block in interval_run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `loop'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `interval_run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:372:in `run_application'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
C:/opscode/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
C:/opscode/chef/bin/chef-client:64:in `load'
C:/opscode/chef/bin/chef-client:64:in `<main>'
I have tried different versions of the chef-client to resolve the issue, but that did not help. I'm not sure if the problem is with the jenkins recipe, chef-provisioning, or what.
Because the jenkins recipes work on a local vagrant machine running the same OS (win 2012 R2), I'm thinking this may be a problem with chef-provisioning-fog.
It turns out the problem is with WinRM. The current version of the chef-provisioning-fog driver hard-codes the AWS user data in order to set up WinRM on the machine. Part of this setup sets the per-shell memory limit to 300MB, and the java command executed by the jenkins recipe wants to reserve 2GB of heap; hence the fatal error.
The short-term fix is to up the per-shell WinRM limit from 300MB to 2GB:
set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048
With chef-provisioning, put this resource after getting the machine ready and before converging:
machine_execute 'set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048' do
machine "jenkins-win-slave-#{i}"
end
Long term, hopefully the issue is resolved and user data can be customized to set up winrm however the user sees fit.