lib/bluepill/controller.rb in kostya-bluepill-0.0.60.2 vs lib/bluepill/controller.rb in kostya-bluepill-0.0.60.3

- old
+ new

@@ -1,13 +1,14 @@ # -*- encoding: utf-8 -*- require 'fileutils' module Bluepill class Controller - attr_accessor :base_dir, :sockets_dir, :pids_dir + attr_accessor :base_dir, :log_file, :sockets_dir, :pids_dir def initialize(options = {}) + self.log_file = options[:log_file] self.base_dir = options[:base_dir] || File.join(ENV['HOME'], '.bluepill') self.sockets_dir = File.join(base_dir, 'socks') self.pids_dir = File.join(base_dir, 'pids') setup_dir_structure @@ -39,9 +40,19 @@ ::Process.kill("TERM", pid) puts "Killing bluepill[#{pid}]" else puts "bluepill[#{pid}] not running" end + when :log + log_file_location = self.send_to_daemon(application, :log_file) + log_file_location = self.log_file if log_file_location.to_s.strip.empty? + + requested_pattern = args.first + grep_pattern = self.grep_pattern(application, requested_pattern) + + tail = "tail -n 100 -f #{log_file_location} | grep -E '#{grep_pattern}'" + puts "Tailing log for #{requested_pattern}..." + Kernel.exec(tail) else $stderr.puts "Unknown command `%s` (or application `%s` has not been loaded yet)" % [command, command] exit(1) end end