12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

td-agentのcapistranoレシピ

Posted at

レシピです。

※setupタスクは、随時変更してください。

set_default(:conf_file) { "/etc/td-agent/td-agent.conf" }

namespace :td_agent do
  desc "start td-agent"
  task :start,  roles: :web do
    run "#{sudo} /etc/init.d/td-agent start"
  end

  desc "stop td-agent"
  task :stop,  roles: :web do
    run "#{sudo} /etc/init.d/td-agent stop"
  end

  desc "restart td-agent"
  task :restart,  roles: :web do
    run "#{sudo} /etc/init.d/td-agent restart"
  end

  desc "reload the config file"
  task :reload, roles: :web do
    run "#{sudo} /etc/init.d/td-agent reload"
  end

  desc "install td-agent by yum"
  task :install, roles: :web do
    run "#{sudo} yum -y install td-agent"
    run "#{sudo} /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-forest"
    run "#{sudo} /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-tail-ex"
  end

  desc "setup config files and log files"
  task :setup, roles: :web do
    run "#{sudo} mkdir -p /var/log/fluent"
    run "#{sudo} chgrp td-agent /var/log/fluent"
    run "#{sudo} chown td-agent /var/log/fluent"
    run "#{sudo} chmod +x /etc/td-agent"
    run "#{sudo} chmod o+w #{conf_file}"
    template("td_agent.erb", conf_file)
  end

  namespace :log do
    task :tail, roles: :web do
      run "#{sudo} tail -f /var/log/td-agent/td-agent.log"
    end
  end
end

after "deploy:install", "td_agent:install"
after "deploy:install", "td_agent:setup"
after "deploy:cleanup", "td_agent:restart"
12
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?