How can I instruct Capistrano 3 to load my shell environment variables set at remote host?

后端 未结 4 1140
有刺的猬
有刺的猬 2021-02-05 16:00

I want to instruct Capistrano to load environment variables that are defined on remote server. How can I do that?

It seems that when I export my environment variables in

4条回答
  •  借酒劲吻你
    2021-02-05 16:18

    You can pass your current environment variables to a remote execution with ssh by issuing:

    env | ssh user@host remote_program
    

    Also taken the example from here

    on roles(:app), in: :sequence, wait: 5 do
      within "/opt/sites/example.com" do
        # commands in this block execute in the
        # directory: /opt/sites/example.com
        as :deploy  do
          # commands in this block execute as the "deploy" user.
          with rails_env: :production do
            # commands in this block execute with the environment
            # variable RAILS_ENV=production
            rake   "assets:precompile"
            runner "S3::Sync.notify"
          end
        end
      end
    end
    

    looks like you can use with set environment variables for your execution. So read your current environment variables and set them using with .

提交回复
热议问题