Sha256: 3e165fd4b1b81df1a028dd18178fb876936eac7f9c2a19ec008e77568ee62917
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 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 ALLOWED_COMMANDS.include?(ARGV.first) if controller.list.length == 1 options[:application] = controller.list.first elsif controller.list.length > 1 $stderr.puts "You must specify an application name. Here's the list:" controller.list.each_with_index do |app, index| $stderr.puts " #{index + 1}. #{app}" end $stderr.puts "Usage: bluepill [app] cmd [options]" exit else $stderr.puts "There are no running bluepill daemons.\nTo start a bluepill daemon, use: bluepill load <config file>" exit end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bluepill-0.0.14 | bin/bluepill |