Using Configuration Variables with IronWorker

There are three primary methods of setting important configuration information for your IronWorker, setting the config variable, sending your worker the variables via the payload/params, and finally through our hud interface

Table of Contents

Set config variables via Worker's task payload/params

When queueing up a task you can easily pass configuration information via the payload. Each enviroment has it's own way to access parameters inside a worker. in ruby you access it by calling the params variable, in php you access it via ``` php $postdata = file_get_contents("php://input"); ```

This is preferable when your worker may have different variations, adapters or strategies when receiving different types of payload.

That's it. The next example walks you through setting a static configuration on you IronWorker upon upload

Set config variables on upload via .yml or .json

First create a .yml or a .json file and save it within your worker directory or directory where you will be running your IronWorker commandline tools from ex: config.yml or config.json

config.json
{ "MY_CONFIG_VARIABLE": 12345678901234567890,
  "MY_CONFIG_VARIABLE2": "ASDGFHJTHFVCBDXFGHSF",}
config.yml
"MY_CONFIG_VARIABLE": 12345678901234567890
"MY_CONFIG_VARIABLE2": "ASDGFHJTHFVCBDXFGHSF"

Next run your standard upload command

iron_worker upload --worker-config config.yml

and you should see in the upload logs that your configuration variables were uploaded with your worker

config-uploaded

When your task is run, a file containing this configuration will be available to your worker and the location of this file will be provided via the program args right after -config. For example, to load your config with Ruby:

require 'json'
config = {}
ARGV.each_with_index do |arg, i|
  if arg == "-config"
    config = JSON.parse(IO.read(ARGV[i+1]))
  end
end

Set config variables in the Iron.io HUD aka dashboard

it is often times useful to change configuration variables without having to reupload your code. We allow you to do so visually with our HUD (dashboard) by following two simple steps.

Navigate to the hud http://hud.iron.io. next navigate to your uploaded code's information by clicking on the code tab and your worker's name. NOTE: for those who remotely build their workers, please make sure you select your worker and not the remote build process

hud-view-code

Through your Worker Code's dashboard you have a useful box where you can change your configuration information in yml format! i.e Key seperated by a colon and the value without quotations and no commas delimiting the values.

hud-config-setup

click edit and...voila! your worker now has updated configuration variables without having to reupload your worker or enter the commandline!