Pergunta

It's common practice on Heroku to have environment variables hold sensitive credentials so that one doesn't need to check in a passsword file into git.

Is there something similar for IronWorkers? How should one go about passing db connection strings to an IronWorker that has to connect to a database? Ideally, I would like to avoid having usernames and passwords in database.yml.

eg:

$ heroku config

HEROKU_POSTGRESQL_CYAN_URL: postgres://mmuxxxxxxxnhzp:X0JdWLxxxcJQ4ffO0xTjO6scJr@ec2-23-23-214-251.compute-1.amazonaws.com:5432/de11tlh7iq999x

$ heroku config:set SOMEVAR=somevalue

SOMEVAR=somevalue

Any help would be appreciated!

Thanks, Dimitri

Foi útil?

Solução

1) Merge config file into package

2) upload worker with --worker-config flag.e.g. iron_worker upload hello.worker --worker-config cfg.json and use config helper inside worker.

3) Pass connection data via payload

Outras dicas

Funny you should ask, an IronCast just went out yesterday on our blog about connecting to databases from your IronWorker's:

http://blog.iron.io/2013/10/ironcast-4-how-to-connect-to-your.html

To pass it in the payload:

@client.tasks.create("pygments",
                     "database" => Rails.configuration.database_configuration[Rails.env],
                     "request" => {"lang" => @snippet.language,
                     "code" => @snippet.plain_code},
                     "snippet_id" => @snippet.id)

Then to use it in your worker:

ActiveRecord::Base.establish_connection(params['database'])
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top