puggernaut 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +15 -22
- data/config/gemsets.yml +1 -0
- data/config/gemspec.yml +2 -1
- data/lib/puggernaut.rb +1 -0
- data/lib/puggernaut/server.rb +3 -1
- data/lib/puggernaut/server/http.rb +2 -0
- data/public/puggernaut.js +3 -8
- metadata +20 -4
data/README.md
CHANGED
@@ -15,11 +15,12 @@ gem install puggernaut
|
|
15
15
|
How it works
|
16
16
|
------------
|
17
17
|
|
18
|
-
Puggernaut consists of
|
18
|
+
Puggernaut consists of four pieces:
|
19
19
|
|
20
20
|
* TCP client to send push messages
|
21
21
|
* TCP server to receive push messages
|
22
|
-
*
|
22
|
+
* TCP server to deliver messages via WebSockets ([em-websocket](https://github.com/igrigorik/em-websocket))
|
23
|
+
* HTTP server to deliver messages via long poll
|
23
24
|
|
24
25
|
Start it up
|
25
26
|
-----------
|
@@ -27,34 +28,25 @@ Start it up
|
|
27
28
|
Run the <code>puggernaut</code> binary with optional port numbers:
|
28
29
|
|
29
30
|
<pre>
|
30
|
-
puggernaut <http port> <tcp port>
|
31
|
+
puggernaut <http port> <tcp port> <tcp port (websocket)>
|
31
32
|
</pre>
|
32
33
|
|
33
|
-
The default HTTP and TCP ports are 8100 and
|
34
|
+
The default HTTP and TCP ports are 8100, 8101, and 8102, respectively.
|
34
35
|
|
35
36
|
Set up proxy pass
|
36
37
|
-----------------
|
37
38
|
|
38
|
-
|
39
|
+
Set up a URL on your public facing web server that points to the Puggernaut HTTP server (long poll).
|
39
40
|
|
40
|
-
|
41
|
+
We all use Nginx, right?
|
41
42
|
|
42
|
-
###
|
43
|
-
|
44
|
-
*http.conf*
|
43
|
+
### nginx.conf
|
45
44
|
|
46
45
|
<pre>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
### Nginx
|
52
|
-
|
53
|
-
*nginx.conf*
|
54
|
-
|
55
|
-
<pre>
|
56
|
-
location /long_poll {
|
57
|
-
proxy_pass http://localhost:8100/;
|
46
|
+
server {
|
47
|
+
location /long_poll {
|
48
|
+
proxy_pass http://localhost:8100/;
|
49
|
+
}
|
58
50
|
}
|
59
51
|
</pre>
|
60
52
|
|
@@ -79,7 +71,8 @@ Include [jQuery](http://jquery.com) and [puggernaut.js](https://github.com/winto
|
|
79
71
|
Javascript client example:
|
80
72
|
|
81
73
|
<pre>
|
82
|
-
Puggernaut.path = '/long_poll'; // (default)
|
74
|
+
Puggernaut.path = '/long_poll'; // (default long poll path)
|
75
|
+
Puggernaut.port = 8102; // (default WebSocket port)
|
83
76
|
|
84
77
|
Puggernaut
|
85
78
|
.watch('channel', function(e, message) {
|
@@ -99,7 +92,7 @@ Specs are a work in progress, though we can vouch for some of the functionality
|
|
99
92
|
|
100
93
|
Set up Nginx to point to a cloned copy of this project:
|
101
94
|
|
102
|
-
|
95
|
+
### nginx.conf
|
103
96
|
|
104
97
|
<pre>
|
105
98
|
server {
|
data/config/gemsets.yml
CHANGED
data/config/gemspec.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
name: puggernaut
|
2
|
-
version: 0.2.
|
2
|
+
version: 0.2.1
|
3
3
|
authors:
|
4
4
|
- Winton Welsh
|
5
5
|
email: mail@wintoni.us
|
@@ -9,4 +9,5 @@ description: Simple server push implementation using eventmachine and long polli
|
|
9
9
|
dependencies:
|
10
10
|
- em-websocket
|
11
11
|
- eventmachine
|
12
|
+
- memprof
|
12
13
|
development_dependencies: null
|
data/lib/puggernaut.rb
CHANGED
data/lib/puggernaut/server.rb
CHANGED
@@ -14,8 +14,8 @@ module Puggernaut
|
|
14
14
|
puts "*snort*\n\n"
|
15
15
|
|
16
16
|
begin
|
17
|
+
Memprof.start
|
17
18
|
Channel.channels = []
|
18
|
-
GC.start
|
19
19
|
EM.epoll if EM.epoll?
|
20
20
|
EM.run do
|
21
21
|
logger.info "Server#initialize - Starting HTTP - #{http_port}"
|
@@ -29,6 +29,8 @@ module Puggernaut
|
|
29
29
|
|
30
30
|
errors = 0
|
31
31
|
end
|
32
|
+
Memprof.stats(Dir.pwd + '/log/puggernaut.mem.log')
|
33
|
+
Memprof.stop
|
32
34
|
rescue Interrupt
|
33
35
|
logger.info "Server#initialize - Shutting down"
|
34
36
|
exit
|
data/public/puggernaut.js
CHANGED
@@ -4,13 +4,14 @@ var Puggernaut = new function() {
|
|
4
4
|
var self = this;
|
5
5
|
|
6
6
|
this.disabled = false;
|
7
|
+
this.host = window.location.host;
|
7
8
|
this.path = '/long_poll';
|
9
|
+
this.port = 8102;
|
8
10
|
this.inhabitants = inhabitants;
|
9
11
|
this.unwatch = unwatch;
|
10
12
|
this.watch = watch;
|
11
13
|
this.watch_join = watch_join;
|
12
14
|
this.watch_leave = watch_leave;
|
13
|
-
this.webSocketPort = webSocketPort;
|
14
15
|
|
15
16
|
var channels = {};
|
16
17
|
var errors = 0;
|
@@ -19,7 +20,6 @@ var Puggernaut = new function() {
|
|
19
20
|
var started = false;
|
20
21
|
var request;
|
21
22
|
var request_id;
|
22
|
-
var port = 8102;
|
23
23
|
|
24
24
|
function ajax(join_leave, time, user_id) {
|
25
25
|
if (channelLength() > 0 && !self.disabled && errors <= 10) {
|
@@ -190,7 +190,7 @@ var Puggernaut = new function() {
|
|
190
190
|
function websocket(join_leave, time, user_id) {
|
191
191
|
if (channelLength() > 0 && !self.disabled && errors <= 10) {
|
192
192
|
started = true;
|
193
|
-
request = new WebSocket("ws://" +
|
193
|
+
request = new WebSocket("ws://" + self.host + ":" + self.port + "/");
|
194
194
|
request.onopen = function() {
|
195
195
|
errors = 0;
|
196
196
|
if (started)
|
@@ -216,9 +216,4 @@ var Puggernaut = new function() {
|
|
216
216
|
};
|
217
217
|
}
|
218
218
|
}
|
219
|
-
|
220
|
-
function webSocketPort(p) {
|
221
|
-
if (p) port = p;
|
222
|
-
return port;
|
223
|
-
}
|
224
219
|
};
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puggernaut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,22 @@ dependencies:
|
|
50
50
|
version: 0.12.10
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: memprof
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 7
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 3
|
65
|
+
- 10
|
66
|
+
version: 0.3.10
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
53
69
|
description: Simple server push implementation using eventmachine and long polling
|
54
70
|
email: mail@wintoni.us
|
55
71
|
executables:
|