Sha256: 2cc1c11412eac9ecb9fdb25a666e043158e32b5fd350deb3e1d91bbfdbd5ea3c

Contents?: true

Size: 1.78 KB

Versions: 8

Compression:

Stored size: 1.78 KB

Contents

#!/usr/bin/env ruby
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib]))
require 'eye/loader'
require 'optparse'
require 'eye'

options = {:debug => false}

OptionParser.new do |opts|
  opts.on( '-h', '--help', 'Display this screen' ) do
    puts opts
    exit
  end

  opts.on( '-c', '--config CONFIG', 'load with config' ) do |config_path|
    options[:config] = config_path
  end

  opts.on( '-s', '--socket SOCKET', 'start listen on socket' ) do |socket_path|
    options[:socket_path] = socket_path
  end

  opts.on( '-l', '--logger LOGGER', 'custom logger' ) do |logger|
    options[:logger] = logger
  end

  opts.on( '-dr', '--dir DIR', 'Dir for local runner' ) do |dir|
    Eye::Local.dir = dir
    Eye::Local.local_runner = true
  end

  opts.on( '-st', '--stop_all', 'Stop all on exit' ) do |stop_all|
    options[:stop_all] = true
  end

  opts.on( '-d', '--debug', 'debug info to logger' ) do
    options[:debug] = true
  end

end.parse!

Eye::Local.ensure_eye_dir

socket_path = options[:socket_path] || Eye::Local.socket_path
server = Eye::Server.new(socket_path)

Eye::Logger.log_level = options[:debug] ? Logger::DEBUG : Logger::INFO
Eye::Logger.link_logger(options[:logger]) if options[:logger]

config = options[:config]
config = File.expand_path(config) if config && !config.empty?

Eye::Control # preload

if config
  res = server.command('load', config)
  exit(1) if res.values.any? { |r| r[:error] }
end

Eye::Control.set_proc_line

server.async.run

trap("USR1") { Eye::Logger.reopen }
trap("USR2") { GC.start }
trap("INT")  { Eye::Logger.info("INT signal <#{$$}>"); exit }
trap("QUIT") { Eye::Logger.info("QUIT signal <#{$$}>"); exit }
trap("TERM") { Eye::Logger.info("TERM signal <#{$$}>"); exit }

at_exit { Eye::Control.command(:stop_all) } if options[:stop_all]

sleep

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
eye-0.8.pre2 bin/loader_eye
eye-0.8.pre bin/loader_eye
eye-0.7 bin/loader_eye
eye-0.7.pre bin/loader_eye
eye-0.6.4 bin/loader_eye
eye-0.6.3 bin/loader_eye
eye-0.6.2 bin/loader_eye
eye-0.6.2.pre bin/loader_eye