Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot access params #160

Closed
fred opened this issue Oct 31, 2013 · 3 comments
Closed

cannot access params #160

fred opened this issue Oct 31, 2013 · 3 comments

Comments

@fred
Copy link

fred commented Oct 31, 2013

On some workers I cannot access params.
I pass the parameters to the job correctly, but when on the worker when I try to access params, it's nil.

example code:

require 'common/base'

unless ARGV.include?("-id")
  params = {'name' => 'homespace'}
end

unless params['name']
  p "'name' parameter is missing, aborting execution..."
  exit
end

error output:

WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
/task/xml_data_fetcher_worker.rb:7:in `<top (required)>': undefined method `[]' for nil:NilClass (NoMethodError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from __runner__.rb:213:in `<main>'

the payload looks just fine when viewed by the web ui:

{
  "name": "homespace"
}

Any ideas?
I recently had to add "@use_local_iron_worker_ng = true" to my .worker file to be able to remote build a ruby worker.
without that line, ruby workers cant build (#159)

@fred
Copy link
Author

fred commented Nov 1, 2013

I also tried running the ruby worker with just this line on top:

p "params: #{params.inspect}"

I still get params: nil

anybody at Iron.io can help?
I cant run any worker at moment, I'm stuck.

@treeder
Copy link
Contributor

treeder commented Nov 1, 2013

Hi @fred , can you print the raw payload instead?

p "payload: #{payload.inspect}"

@fred
Copy link
Author

fred commented Nov 4, 2013

I managed to solve this problem.
when using "require_relative" method on the worker, params is nil, so I have to use just "require"

for example

# this causes params to be nil
require_relative 'common/base'

# but this is ok
require 'common/base'

Very strange issue.

ps: I run Ruby 2.0 locally, but iron.io is still on 1.9.3p0, maybe that could be a cause?

Best regards.
Fred

@fred fred closed this as completed Nov 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants