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 Dashboard 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. You can read more about payloads here.

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 your IronWorker upon upload.

Set config variables on upload via a json file

First create .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

```sh { "project_id":"1234567890abcderghijklmn", "token":"0987654321uhgtehrrgfgdhrhfg" "MY_CONFIG_VARIABLE": 12345678901234567890, "MY_CONFIG_VARIABLE2": "ASDGFHJTHFVCBDXFGHSF" } ```

Next run your standard upload command

```sh iron worker upload --config-file config.json --name myworker --zip iron/images:ruby-2.1 ruby worker.rb ```

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 `CONFIG_FILE` environment variable. To get the contents of your config, you need to: 1. Read the `CONFIG_FILE` environment variable using whatever your language uses to read env variables. 2. Open and read the file specified by the `CONFIG_FILE` variable 3. Parse the contents of the file as JSON Most of our [client libraries](/worker/libraries/) have helper methods to help with this, see your client libs docs for more information. *Note: Instead of JSON you are free to use any other format like [YAML](, though it may not be supported by the client libs and you will have to parse the content by yourself*

Set config variables in the 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 Dashboard by following two simple steps.

Navigate to the Dashboard 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

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.


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