#!/usr/bin/ruby
require 'dynflow'
require 'rack'
require 'smart_proxy_dynflow_core/launcher'
require 'yaml'
require 'optparse'

options = {}
OptionParser.new do |opts|
  opts.on('-c', '--config-dir CONFIG_DIR', String, 'Directory to load settings from') do |value|
    options[:config_dir] = value
  end

  opts.on('-1', '--one-config', 'Do not load more than 1 config') do |value|
    options[:one_config] = true
  end

  opts.on('-d', '--[no-]daemonize', 'Fork to background after start') do |value|
    options[:daemonize] = value
  end

  opts.on('-p', '--pid-file PID_FILE', String, 'Write pid to this file') do |value|
    options[:pid_file] = value
  end

  opts.on_tail('-h', '--help', 'Show usage help') do
    puts opts
    exit
  end
end.parse!

SmartProxyDynflowCore::Launcher.launch! options
