ernicorn 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -19,25 +19,32 @@ Installation
19
19
  Starting The Server
20
20
  -------------------
21
21
 
22
- Use the ernicorn command to start a new RPC server:
22
+ Use the `ernicorn` command to start a new RPC server:
23
23
 
24
- [rtomayko@iron:ernicorn]$ ernicorn --help
25
- Ernicorn is an Ruby BERT-RPC Server based on Unicorn.
24
+ $ ernicorn --help
25
+ Usage: ernicorn [options] [config file]
26
+ Start a Ruby BERT-RPC Server with the given options and config file.
26
27
 
27
- Basic Command Line Usage:
28
- ernicorn [options] <handler>
28
+ Options
29
+ -h, --host=<host> Server address to listen on; default: 0.0.0.0
30
+ -p, --port=<portno> Server port to listen on; default: 8149
31
+ -l, --listen=<host>:<port> Listen addresses. Can be specified multiple times
32
+ --log-level=0-4 Set the log level
33
+ -d, --detached Run as a daemon
34
+ -P, --pidfile=<file> Location to write pid file
29
35
 
30
- -c, --config CONFIG Unicorn style config file
31
- -p, --port PORT Port
32
- -l, --log-level LOGLEVEL Log level (0-4)
33
- -d, --detached Run as a daemon
34
- -P, --pidfile PIDFILE Location to write pid file.
36
+ The ernicorn server attempts to load the config file given or
37
+ `config/ernicorn.rb` when no config file is specified. See the example config
38
+ file [examples/config.rb][c] to get started. All [Unicorn config options][r] are
39
+ supported.
35
40
 
36
- The handler must be given and should be a normal Ruby file that sets up the
37
- environment and calls `Ernicorn.expose` for any server modules. See the
38
- [examples/handler.rb][h] file for more info.
41
+ The config file should require any libraries needed for the server and register
42
+ server modules with `Ernicorn.expose(:modulename, TheModule)`. See the
43
+ [examples/handler.rb][h] file for a simple example handler.
39
44
 
40
45
  [h]: https://github.com/github/ernicorn/blob/master/examples/handler.rb
46
+ [c]: https://github.com/github/ernicorn/blob/master/examples/config.rb
47
+ [r]: http://unicorn.bogomips.org/Unicorn/Configurator.html
41
48
 
42
49
  Control Commands
43
50
  ----------------
@@ -1,10 +1,12 @@
1
+ require 'ernicorn/version'
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.specification_version = 2 if s.respond_to? :specification_version=
3
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
6
  s.rubygems_version = '1.3.6'
5
7
 
6
8
  s.name = 'ernicorn'
7
- s.version = '1.0.1'
9
+ s.version = Ernicorn::VERSION
8
10
  s.date = '2012-06-23'
9
11
 
10
12
  s.summary = "Ernicorn is a BERT-RPC server implementation based on unicorn."
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
2
  # Start the example ernicorn server on port 9777.
3
3
  cd "$(dirname "$0")"
4
- exec ernicorn -p 9777 config.rb
4
+ exec ernicorn config.rb
@@ -1,9 +1,8 @@
1
1
  require 'bert'
2
2
  require 'logger'
3
+ require 'ernicorn/version'
3
4
 
4
5
  module Ernicorn
5
- VERSION = '1.0.0'
6
-
7
6
  class << self
8
7
  attr_accessor :mods, :current_mod, :log
9
8
  attr_accessor :count, :virgin_procline
@@ -0,0 +1,3 @@
1
+ module Ernicorn
2
+ VERSION = '1.0.2'
3
+ end
@@ -4,41 +4,58 @@
4
4
  #/
5
5
  #/ Options
6
6
  #/ -h, --host=<host> Server address to listen on; default: 0.0.0.0
7
- #/ -p, --port=<portno> Server port to listen on; default: 8000
7
+ #/ -p, --port=<portno> Server port to listen on; default: 8149
8
+ #/ -l, --listen=<host>:<port> Listen addresses. Can be specified multiple times
8
9
  #/ --log-level=0-4 Set the log level
9
10
  #/ -d, --detached Run as a daemon
10
11
  #/ -P, --pidfile=<file> Location to write pid file
11
12
  #/
12
13
  #/ See https://github.com/github/ernicorn for more information.
13
14
  require 'optparse'
15
+
16
+ # override unicorn's default port and listen address list
17
+ module Unicorn
18
+ require 'unicorn/const'
19
+ module Unicorn::Const
20
+ remove_const :DEFAULT_PORT
21
+ remove_const :DEFAULT_LISTEN
22
+ DEFAULT_PORT = 8149
23
+ DEFAULT_LISTEN = "#{DEFAULT_HOST}:#{DEFAULT_PORT}"
24
+ end
25
+ end
26
+
27
+ # load unicorn server extensions
14
28
  require 'ernicorn'
15
29
  require 'ernicorn/server'
16
30
  require 'ernicorn/adminrpc'
17
31
 
18
- Ernicorn.auto_start = false
19
-
20
- host = '0.0.0.0'
21
- port = 8000
32
+ # command line options
33
+ host = nil
34
+ port = nil
35
+ listeners = []
22
36
  daemonize = false
23
37
  config = 'config/ernicorn.rb'
24
38
  pidfile = nil
25
39
 
26
40
  parser = OptionParser.new do |opts|
27
- opts.on("-c", "--config=val", String) { |config| }
28
- opts.on("-h", "--host=val", Integer) { |host| }
29
- opts.on("-p", "--port=val", Integer) { |port| }
30
- opts.on( "--log-level=val", Integer) { |val| Ernicorn.loglevel(val) }
31
- opts.on("-d", "--detached") { |daemonize| }
32
- opts.on("-P", "--pidfile=val") { |pidfile| }
33
- opts.on_tail("-h", "--help") { exec "grep ^#/<'#{__FILE__}'|cut -c4-" }
41
+ opts.on("-c", "--config=val", String) { |config| }
42
+ opts.on("-h", "--host=val", String) { |host| }
43
+ opts.on("-p", "--port=val", Integer) { |port| }
44
+ opts.on("-l", "--listen=val", String) { |addr| listeners << addr }
45
+ opts.on( "--log-level=val", Integer) { |val| Ernicorn.loglevel(val) }
46
+ opts.on("-d", "--detached") { |daemonize| }
47
+ opts.on("-P", "--pidfile=val") { |pidfile| }
48
+ opts.on_tail("-h", "--help") { exec "grep ^#/<'#{__FILE__}'|cut -c4-" }
34
49
  opts.parse!
35
50
  end
36
51
 
52
+ listeners << "#{host || '0.0.0.0'}:#{port || 8149}" if host || port
53
+
37
54
  config = ARGV[0] || config
38
55
 
39
56
  options = {
40
57
  :pid => pidfile,
41
- :listeners => ["#{host}:#{port}"],
58
+ :listeners => listeners,
42
59
  :config_file => File.expand_path(config)
43
60
  }
44
61
 
@@ -10,7 +10,7 @@
10
10
  require 'optparse'
11
11
  require 'bertrpc'
12
12
 
13
- port = 8000
13
+ port = 8149
14
14
 
15
15
  def usage(status=0)
16
16
  exec "grep ^#/<'#{__FILE__}'|cut -c4-; exit #{status}"
@@ -1,4 +1,3 @@
1
1
  require 'test/unit'
2
2
  require 'shoulda'
3
3
  require 'ernicorn'
4
- Ernicorn.auto_start = false
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tom Preston-Werner
@@ -98,6 +98,7 @@ files:
98
98
  - lib/ernicorn.rb
99
99
  - lib/ernicorn/adminrpc.rb
100
100
  - lib/ernicorn/server.rb
101
+ - lib/ernicorn/version.rb
101
102
  - script/bootstrap
102
103
  - script/cibuild
103
104
  - script/ernicorn