nutcracker-web 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -0
- data/README.md +51 -0
- data/bin/nutcracker-web +98 -0
- data/lib/nutcracker/web/version.rb +1 -1
- data/lib/nutcracker/web.rb +4 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bef0363a281acf0545f3616b258d4f8d6f1b938
|
4
|
+
data.tar.gz: 0214c654bee10878930cd57a471d41c075aac8c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 154f7d879843a9558eb97800156c9f359f9b245e8bfafda9782593b29d4301b193eb80546d1dca29228c7d9d991ab7e747b908414238611a047747a1a969ab29
|
7
|
+
data.tar.gz: cb04e9ce6042be389f86b5da61860de1a933d4e1696b84cfe4c340d06306cff6c5871e041d8324be953d3a5b36ebe1e0e3f4c53d81460c2db007a449c06cab7f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -19,9 +19,12 @@ GEM
|
|
19
19
|
hike (1.2.2)
|
20
20
|
json (1.8.0)
|
21
21
|
multi_json (1.7.5)
|
22
|
+
nutcracker (0.3.0.12)
|
23
|
+
redis
|
22
24
|
rack (1.5.2)
|
23
25
|
rack-protection (1.5.0)
|
24
26
|
rack
|
27
|
+
redis (3.0.7)
|
25
28
|
sinatra (1.4.2)
|
26
29
|
rack (~> 1.5, >= 1.5.2)
|
27
30
|
rack-protection (~> 1.4)
|
@@ -48,6 +51,7 @@ DEPENDENCIES
|
|
48
51
|
eco
|
49
52
|
haml
|
50
53
|
json
|
54
|
+
nutcracker
|
51
55
|
sinatra
|
52
56
|
sprockets
|
53
57
|
thin
|
data/README.md
CHANGED
@@ -25,6 +25,57 @@ gem install nutcracker-web
|
|
25
25
|
```
|
26
26
|
|
27
27
|
## Usage
|
28
|
+
```
|
29
|
+
$ nutcracker-web --help
|
30
|
+
Usage: nutcracker-web [web-options] -- [nutcracker-options]
|
31
|
+
|
32
|
+
[web-options]
|
33
|
+
|
34
|
+
-s, --stats-port PORT Nutcracker stats port - 22222
|
35
|
+
-c, --config FILE Nutcracker cluster config file
|
36
|
+
-p, --port PORT Web interface listening port
|
37
|
+
-b, --backend BACKEND Web server to use ( needs to be Rack compliant )
|
38
|
+
-d, --daemonize run in background
|
39
|
+
-l, --launch launch Nutcracker instance as well
|
40
|
+
-i, --pid FILE pid file
|
41
|
+
|
42
|
+
[nutcracker-options]
|
43
|
+
|
44
|
+
-h, --help : this help
|
45
|
+
-V, --version : show version and exit
|
46
|
+
-t, --test-conf : test configuration for syntax errors and exit
|
47
|
+
-d, --daemonize : run as a daemon
|
48
|
+
-D, --describe-stats : print stats description and exit
|
49
|
+
-v, --verbosity=N : set logging level (default: 5, min: 0, max: 11)
|
50
|
+
-o, --output=S : set logging file (default: stderr)
|
51
|
+
-c, --conf-file=S : set configuration file (default: conf/nutcracker.yml)
|
52
|
+
-s, --stats-port=N : set stats monitoring port (default: 22222)
|
53
|
+
-a, --stats-addr=S : set stats monitoring ip (default: 0.0.0.0)
|
54
|
+
-i, --stats-interval=N : set stats aggregation interval in msec (default: 30000 msec)
|
55
|
+
-p, --pid-file=S : set pid file (default: off)
|
56
|
+
-m, --mbuf-size=N : set size of mbuf chunk in bytes (default: 16384 bytes)
|
57
|
+
|
58
|
+
```
|
59
|
+
|
60
|
+
conneting to a running instance of Nutcracker and running the web interface on port 22122
|
61
|
+
```
|
62
|
+
$ nutcracker-web --config /etc/nutcracker/cluster.yml --port 22122
|
63
|
+
[2014-03-02 17:26:40] INFO WEBrick 1.3.1
|
64
|
+
[2014-03-02 17:26:40] INFO ruby 2.0.0 (2013-05-14) [x86_64-darwin11.4.2]
|
65
|
+
[2014-03-02 17:26:40] INFO WEBrick::HTTPServer#start: pid=84800 port=22122
|
66
|
+
```
|
67
|
+
|
68
|
+
launching Nutcracker and nutcracker-web
|
69
|
+
```
|
70
|
+
$ nutcracker-web --config /etc/nutcracker/cluster.yml --port 22122 --launch
|
71
|
+
[Sun Mar 2 17:26:37 2014] nc.c:187 nutcracker-0.3.0 built for Darwin 13.0.0 x86_64 started on pid 84801
|
72
|
+
[Sun Mar 2 17:26:37 2014] nc.c:192 run, rabbit run / dig that hole, forget the sun / and when at last the work is done / don't sit down / it's time to dig another one
|
73
|
+
[2014-03-02 17:26:40] INFO WEBrick 1.3.1
|
74
|
+
[2014-03-02 17:26:40] INFO ruby 2.0.0 (2013-05-14) [x86_64-darwin11.4.2]
|
75
|
+
[2014-03-02 17:26:40] INFO WEBrick::HTTPServer#start: pid=84800 p
|
76
|
+
```
|
77
|
+
|
78
|
+
## Usage via code
|
28
79
|
After starting the nutcracker service via [nutcracker-ruby](https://github.com/kontera-technologies/nutcracker) just activate the `nutcracker-web` plugin:
|
29
80
|
```ruby
|
30
81
|
require 'nutcracker'
|
data/bin/nutcracker-web
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
$:.unshift File.expand_path('../../lib',__FILE__)
|
3
|
+
|
4
|
+
require 'nutcracker'
|
5
|
+
require 'nutcracker/web'
|
6
|
+
require 'optparse'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'socket'
|
9
|
+
require 'open3'
|
10
|
+
|
11
|
+
options = { stats_port: 22222 }
|
12
|
+
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.set_summary_indent " "
|
15
|
+
|
16
|
+
opts.banner = "Usage: nutcracker-web [web-options] -- [nutcracker-options]"
|
17
|
+
opts.separator ""
|
18
|
+
opts.separator "[web-options]"
|
19
|
+
opts.separator ""
|
20
|
+
|
21
|
+
opts.on("-s", "--stats-port PORT", "Nutcracker stats port - #{options[:stats_port]}") do |v|
|
22
|
+
options[:stats_port] = v.to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-c","--config FILE", "Nutcracker cluster config file") do |v|
|
26
|
+
options[:config_file] = File.expand_path v
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-p","--port PORT", "Web interface listening port") do |v|
|
30
|
+
options[:Port] = v.to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-b","--backend BACKEND", "Web server to use ( needs to be Rack compliant )") do |v|
|
34
|
+
options[:server] = v
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-d", "--daemonize","run in background") do
|
38
|
+
options[:daemonize] = true
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-l", "--launch","launch Nutcracker instance as well") do
|
42
|
+
options[:launch_nutcracker] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-i","--pid FILE","pid file") do |v|
|
46
|
+
options[:pid] = v
|
47
|
+
options[:nutcracker_pid] = v + ".nutcracker"
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.separator ""
|
51
|
+
opts.separator "[nutcracker-options]"
|
52
|
+
Open3.popen3("nutcracker --help") do |_,_,stderr|
|
53
|
+
opts.separator stderr.read.match(/options:(.*)/msi)[1]
|
54
|
+
end rescue nil
|
55
|
+
|
56
|
+
end.parse!
|
57
|
+
|
58
|
+
abort "Please specified nutcracker config file" if options[:config_file].nil?
|
59
|
+
abort "Can't find the specified config file @ #{options[:config_file]}" unless File.exists? options[:config_file]
|
60
|
+
|
61
|
+
args = ARGV.to_a
|
62
|
+
args << "--stats-port" << options[:stats_port]
|
63
|
+
|
64
|
+
if options[:pid]
|
65
|
+
args << "--pid-file" << options[:nutcracker_pid]
|
66
|
+
at_exit { options.values_at(:pid,:nutcracker_pid).map(&FileUtils.method(:rm_rf)) }
|
67
|
+
end
|
68
|
+
|
69
|
+
if options[:daemonize]
|
70
|
+
if RUBY_VERSION < "1.9"
|
71
|
+
exit if fork
|
72
|
+
Process.setsid
|
73
|
+
exit if fork
|
74
|
+
Dir.chdir "/"
|
75
|
+
STDIN.reopen "/dev/null"
|
76
|
+
STDOUT.reopen "/dev/null", "a"
|
77
|
+
STDERR.reopen "/dev/null", "a"
|
78
|
+
else
|
79
|
+
Process.daemon
|
80
|
+
end
|
81
|
+
File.open(options[:pid],'w') { |f| f.write(Process.pid) } rescue nil
|
82
|
+
end
|
83
|
+
|
84
|
+
if options[:launch_nutcracker]
|
85
|
+
nutcracker = Nutcracker.start(options.merge(args: args))
|
86
|
+
else
|
87
|
+
if (TCPSocket.new('127.0.0.1',options[:stats_port]) rescue nil)
|
88
|
+
nutcracker = Nutcracker.attach(options)
|
89
|
+
else
|
90
|
+
abort "Failed to attach, are you sure that Nutcracker is running ?\n" +
|
91
|
+
"the specified stats port is closed ( #{options[:stats_port]} )\n" +
|
92
|
+
"If you want to launch Nutcracker instance as well use the --launch switch"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
server = nutcracker.use(:web, options)
|
97
|
+
|
98
|
+
( options[:launch_nutcracker] ? nutcracker : server ).join
|
data/lib/nutcracker/web.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutcracker-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eran Barak Levi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -110,7 +110,8 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
description: Web interface for Nutcracker cluster
|
112
112
|
email: eran@kontera.com
|
113
|
-
executables:
|
113
|
+
executables:
|
114
|
+
- nutcracker-web
|
114
115
|
extensions: []
|
115
116
|
extra_rdoc_files: []
|
116
117
|
files:
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- lib/nutcracker/web.rb
|
124
125
|
- public/assets/application.css
|
125
126
|
- public/assets/application.js
|
127
|
+
- bin/nutcracker-web
|
126
128
|
homepage: http://www.kontera.com
|
127
129
|
licenses: []
|
128
130
|
metadata: {}
|