ry / ebb fork watch download tarball
public
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
Search Repo:
Ryan Dahl (author)
Mon Mar 03 08:35:51 -0800 2008
commit  eb823db6bb07b9c2f411f0aa62b923d3f8198838
tree    2ab3bf24cd359d84f810217d36f1f1ee40927bcf
parent  9bccca53b6ae1533edf3211ad0ba83a48ed9b5a9
ebb / bin / ebb_rails
100755 79 lines (60 sloc) 2.178 kb
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
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../ruby_lib/ebb'
require 'optparse'
require 'rubygems'
require 'rack'
 
module Rack
  module Adapter
    autoload :Rails, Ebb::LIBDIR + '/rack/adapter/rails'
  end
end
 
options = {
  :root => Dir.pwd,
  :env => 'development',
  :hort => '0.0.0.0',
  :port => 3000,
  :timeout => 60
}
 
 
opts = OptionParser.new do |opts|
  opts.banner = "Usage: ebb_rails [options] start|stop"
 
  opts.separator ""
  opts.separator "Server options:"
 
# opts.on("-s", "--socket SOCKET", "listen on socket") { |socket| options[:socket] = socket }
  opts.on("-p", "--port PORT", "use PORT (default: 3000)") { |port| options[:port] = port }
  opts.on("-e", "--env ENV", "Rails environment (default: development)") { |env| options[:env] = env }
  opts.on("-c", "--chdir PATH", "Rails root dir (default: current dir)") { |dir| options[:root] = dir }
  opts.on("-d", "--daemonize", "Daemonize") { options[:daemonize] = true }
  opts.on("-l", "--log-file FILE", "File to redirect output") { |file| options[:log_file] = file }
  opts.on("-P", "--pid-file FILE", "File to store PID") { |file| options[:pid_file] = file }
  opts.on("-t", "--timeout SEC", "Request or command timeout in sec",
                                 "(default: #{options[:timeout]})") { |sec| options[:timeout] = sec }
 
  opts.separator ""
  opts.separator "Common options:"
 
  opts.on_tail("-h", "--help", "Show this message") do
    puts opts
    exit
  end
 
  opts.on_tail('-v', '--version', "Show version") do
    puts "Ebb #{Ebb::VERSION}"
    exit
  end
 
  opts.parse! ARGV
end
 
case ARGV[0]
  
when 'start'
  app = Rack::Adapter::Rails.new(options)
  server = Ebb::Server.new(app, options)
  
  server.pid_file = options[:pid_file]
  server.log_file = options[:log_file]
  server.timeout = options[:timeout]
  
  server.daemonize if options[:daemonize]
  
  server.start
 
when 'stop'
  Ebb::Server.kill options[:pid_file], options[:timeout]
 
when nil
  puts "Command required"
  puts opts
  exit 1
  
else
  abort "Invalid command : #{ARGV[0]}"
  
end