当前位置: 动力学知识库 > 问答 > 编程问答 >

capistrano3 - environment variables with capistrano 3

问题描述:

What is the best way to add environment variables with capistrano 3?

I've tried both

set :default_env, {

'MAILCHIMP' => 'verylongstring'

}

and

set :default_environment, {

'MAILCHIMP' => 'verylongstring',

}

but none seemed to do anything usefull.

网友答案:

We need to separate between environment variables that are being used when Capistrano are running its tasks (like deploying), and environment variables that Rails are using when running in production mode on the server.

If you need environment variables during a capistrano 3 session then I belive set :default_env is the way to go. (Im still on capistrano 2 myself, so Im not 100% sure).

If you need production mode specific settings and environment variables you probably want something independent of Capistrano, like Figaro or rails_config Why? Because there will likely be situations where Rails is being booted outside of capistrano. For instance, by a startup script running after a server reboot, a rails console session started on the server or a rake task running as a cron job on the server.

分享给朋友:
您可能感兴趣的文章:
随机阅读: