2

我正在玩 New Relic,并希望提醒 New Relic 进行部署。我可以在命令行上使用:

curl -H "x-api-key:MY_API_KEY" -d "deployment[application_id]=MY_APP_ID "https://api.newrelic.com/deployments.xml

我应该在 capfile 中添加什么,以便 capistrano 在部署时运行上面的 curl?

我知道我可以安装新的 relic gem 并在 Capfile 中使用它,但想避免依赖。

4

2 回答 2

3

You can use the "run" command like this:

task :foo, :hosts => "my.example.com" do
  run "curl <your info here>"
end

The "run" command string is typical Ruby, so you can use any string delimiters:

run %{curl -H "x-api-key:MY_API_KEY" -d ... }

And you can embed parameters as usual:

key = "xyz"
run %{curl -H "x-api-key:#{key}" -d ... }

Good info in the comments from Frederick Chung:

The "run" command will run it on all the remote hosts. I'd use run_locally or even just ``.

Use "run" if you want to know that each host does deploy; each host will send its own info to New Relic.

Use "run_locally" if you just want to know that your local script has run, and you don't care to know that each remote host deployed.

于 2012-12-02T00:16:26.510 回答
1

他们现在有自己的 capistrano 食谱:https ://newrelic.com/docs/ruby/recording-deployments-with-the-ruby-agent

于 2013-03-29T22:26:04.483 回答