unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
00c8464176f42e3284bc0adada6e267198129d5e blob 3701 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
 
#!/this/will/be/overwritten/or/wrapped/anyways/do/not/worry/ruby
# -*- encoding: binary -*-
require 'unicorn/launcher'
require 'optparse'

ENV["RACK_ENV"] ||= "development"
rackup_opts = Unicorn::Configurator::RACKUP
options = rackup_opts[:options]
set_no_default_middleware = true

op = OptionParser.new("", 24, '  ') do |opts|
  cmd = File.basename($0)
  opts.banner = "Usage: #{cmd} " \
                "[ruby options] [#{cmd} options] [rackup config file]"
  opts.separator "Ruby options:"

  lineno = 1
  opts.on("-e", "--eval LINE", "evaluate a LINE of code") do |line|
    eval line, TOPLEVEL_BINDING, "-e", lineno
    lineno += 1
  end

  opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") do
    $DEBUG = true
  end

  opts.on("-w", "--warn", "turn warnings on for your script") do
    $-w = true
  end

  opts.on("-I", "--include PATH",
          "specify $LOAD_PATH (may be used more than once)") do |path|
    $LOAD_PATH.unshift(*path.split(':'))
  end

  opts.on("-r", "--require LIBRARY",
          "require the library, before executing your script") do |library|
    require library
  end

  opts.separator "#{cmd} options:"

  # some of these switches exist for rackup command-line compatibility,

  opts.on("-o", "--host HOST",
          "listen on HOST (default: #{Unicorn::Const::DEFAULT_HOST})") do |h|
    rackup_opts[:host] = h
    rackup_opts[:set_listener] = true
  end

  opts.on("-p", "--port PORT", Integer,
          "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |port|
    rackup_opts[:port] = port
    rackup_opts[:set_listener] = true
  end

  opts.on("-E", "--env RACK_ENV",
          "use RACK_ENV for defaults (default: development)") do |e|
    ENV["RACK_ENV"] = e
  end

  opts.on("-N", "--no-default-middleware",
          "do not load middleware implied by RACK_ENV") do |e|
    rackup_opts[:no_default_middleware] = true if set_no_default_middleware
  end

  opts.on("-D", "--daemonize", "run daemonized in the background") do |d|
    rackup_opts[:daemonize] = !!d
  end

  opts.on("-P", "--pid FILE", "DEPRECATED") do |f|
    warn %q{Use of --pid/-P is strongly discouraged}
    warn %q{Use the 'pid' directive in the Unicorn config file instead}
    options[:pid] = f
  end

  opts.on("-s", "--server SERVER",
          "this flag only exists for compatibility") do |s|
    warn "-s/--server only exists for compatibility with rackup"
  end

  # Unicorn-specific stuff
  opts.on("-l", "--listen {HOST:PORT|PATH}",
          "listen on HOST:PORT or PATH",
          "this may be specified multiple times",
          "(default: #{Unicorn::Const::DEFAULT_LISTEN})") do |address|
    options[:listeners] << address
  end

  opts.on("-c", "--config-file FILE", "Unicorn-specific config file") do |f|
    options[:config_file] = f
  end

  # I'm avoiding Unicorn-specific config options on the command-line.
  # IMNSHO, config options on the command-line are redundant given
  # config files and make things unnecessarily complicated with multiple
  # places to look for a config option.

  opts.separator "Common options:"

  opts.on_tail("-h", "--help", "Show this message") do
    puts opts.to_s.gsub(/^.*DEPRECATED.*$/s, '')
    exit
  end

  opts.on_tail("-v", "--version", "Show version") do
    puts "#{cmd} v#{Unicorn::Const::UNICORN_VERSION}"
    exit
  end

  opts.parse! ARGV
end

set_no_default_middleware = false
app = Unicorn.builder(ARGV[0] || 'config.ru', op)
op = nil

if $DEBUG
  require 'pp'
  pp({
    :unicorn_options => options,
    :app => app,
    :daemonize => rackup_opts[:daemonize],
  })
end

Unicorn::Launcher.daemonize!(options) if rackup_opts[:daemonize]
Unicorn::HttpServer.new(app, options).start.join
debug log:

solving 00c8464 ...
found 00c8464 in unicorn.git

unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhbt.net/unicorn-public
	git clone --mirror http://ou63pmih66umazou.onion/unicorn-public

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 unicorn-public unicorn-public/ https://yhbt.net/unicorn-public \
		unicorn-public@yhbt.net unicorn-public@bogomips.org mongrel-unicorn@rubyforge.org mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
	public-inbox-index unicorn-public

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	../../../unicorn.git

AGPL code for this site: git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git