Sha256: 030558d588f59d2771699921ef76f7110ddccd6603cab36fc45f0ce1668d308a
Contents?: true
Size: 1.37 KB
Versions: 10
Compression:
Stored size: 1.37 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'optparse' require 'bluepill' # defaults options = { :log_file => "/var/log/bluepill.log" } OptionParser.new do |opts| opts.banner = "Usage: bluepill [app] cmd [options]" opts.on("--logfile LOGFILE") do |file| options[:log_file] = file end opts.on("--base-dir DIR") do |base_dir| options[:base_dir] = base_dir end end.parse! ALLOWED_COMMANDS = %w(load status start stop restart log unmonitor quit) controller = Bluepill::Controller.new(options.slice(:base_dir)) if controller.list.include?(ARGV.first) options[:application] = ARGV.shift elsif controller.list.length == 1 && ALLOWED_COMMANDS.include?(ARGV.first) options[:application] = controller.list.first end options[:command] = ARGV.shift case options[:command] when "load" file = ARGV.shift eval(File.read(file)) when "log" orig_pattern = pattern = ARGV.shift pattern = controller.send_cmd(options[:application], :grep_pattern, pattern) cmd = "tail -n 100 -f #{options[:log_file]} | grep -E '#{pattern}'" cmd = "echo 'Tailing log for #{orig_pattern}...'; #{cmd}" Kernel.exec(cmd) when *ALLOWED_COMMANDS process_or_group_name = ARGV.shift puts controller.send_cmd(options[:application], options[:command], process_or_group_name) else puts "Unknown command `%s`" % options[:command] end
Version data entries
10 entries across 10 versions & 1 rubygems