Sha256: ec3795b5ce35c277c2914e1f7781de3a9deda685c8b71728a1b5627778c864fb

Contents?: true

Size: 1.61 KB

Versions: 10

Compression:

Stored size: 1.61 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'ostruct'

# add lib to the default include path
unless $:.include?(File.dirname(__FILE__) + '/../lib/')
  $: << File.dirname(__FILE__) + '/../lib'
end

require 'flapjack/configuration'

options = OpenStruct.new
options.config    = File.join('etc', 'flapjack_config.yaml')
options.daemonize = nil

OptionParser.new do |opts|
  opts.banner = "Usage: flapjack [options]"

  opts.on("-c", "--config [PATH]", String, "PATH to the config file to use") do |c|
    options.config = c
  end

  opts.on("-d", "--[no-]daemonize", "Daemonize?") do |d|
    options.daemonize = d
  end

  opts.on("-p", "--pidfile [PATH]", String, "PATH to the pidfile to write to") do |p|
    options.pidfile = p
  end

end.parse!(ARGV)

FLAPJACK_ENV = ENV['FLAPJACK_ENV'] || 'development'

config = Flapjack::Configuration.new
config.load(options.config)
config_env = config.all

if config_env.nil? || config_env.empty?
  puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{options.config}'"
  exit(false)
end

if options.pidfile.nil?
  pid_file = (config_env['pid_file'] || 'tmp/pids/flapjack.pid')
else
  pid_file = options.pidfile
end

# TODO Flapjack falls over when Redis restarted -- trap errors and attempt reconnect

require 'flapjack/coordinator'

coordinator = Flapjack::Coordinator.new(config)
coordinator.log_file = (config_env['log_file'] || 'log/flapjack.log')
coordinator.pid_file = pid_file

if options.daemonize.nil?
  daemonize = !!config_env['daemonize']
else
  daemonize = options.daemonize
end

puts "Daemonising ... " if daemonize
coordinator.start(:daemonize => daemonize, :signals => true)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flapjack-0.6.53 bin/flapjack
flapjack-0.6.52 bin/flapjack
flapjack-0.6.51 bin/flapjack
flapjack-0.6.50 bin/flapjack
flapjack-0.6.49 bin/flapjack
flapjack-0.6.48 bin/flapjack
flapjack-0.6.47 bin/flapjack
flapjack-0.6.46 bin/flapjack
flapjack-0.6.45 bin/flapjack
flapjack-0.6.44 bin/flapjack