Class: Commands::SetupLogrotate

Inherits:
Object
  • Object
show all
Extended by:
Citrin::Helpers
Defined in:
lib/citrin/commands/setup_logrotate.rb

Class Method Summary collapse

Methods included from Citrin::Helpers

database_template_file, logrotate_config_template, rails_app_log_file, webserver_template_file

Class Method Details

.run(app) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/citrin/commands/setup_logrotate.rb', line 5

def self.run(app)
  @app = app
  logfile = rails_app_log_file(@app)
  template_file = logrotate_config_template(@app)
  template = ERB.new(File.read(template_file), 0, "%<>")
  result = template.result(binding)
  output_file = "/etc/logrotate.d/rails-app-#{@app.name}-#{@app.env}"
  puts "Creating logrotate config file at #{output_file}"
  puts result
  `sudo sh -c 'echo "#{result}" > #{output_file}'`
end