puggernaut 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,11 +15,12 @@ gem install puggernaut
15
15
  How it works
16
16
  ------------
17
17
 
18
- Puggernaut consists of three pieces:
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
- * HTTP server to deliver long poll requests
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 &lt;http port&gt; &lt;tcp port&gt;
31
+ puggernaut &lt;http port&gt; &lt;tcp port&gt; &lt;tcp port (websocket)&gt;
31
32
  </pre>
32
33
 
33
- The default HTTP and TCP ports are 8100 and 8101, respectively.
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
- You will need to set up a URL on your public facing web server that points to the Puggernaut HTTP server.
39
+ Set up a URL on your public facing web server that points to the Puggernaut HTTP server (long poll).
39
40
 
40
- If you do not see your web server below, [Google](http://google.com) is your friend.
41
+ We all use Nginx, right?
41
42
 
42
- ### Apache
43
-
44
- *http.conf*
43
+ ### nginx.conf
45
44
 
46
45
  <pre>
47
- ProxyPass /long_poll http://localhost:8100/
48
- ProxyPassReverse /long_poll http://localhost:8100/
49
- </pre>
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
- *nginx.conf*
95
+ ### nginx.conf
103
96
 
104
97
  <pre>
105
98
  server {
@@ -1,6 +1,7 @@
1
1
  puggernaut:
2
2
  em-websocket: ~>0.2.1
3
3
  eventmachine: ~>0.12.10
4
+ memprof: ~>0.3.10
4
5
  rake: >=0.8.7
5
6
  rspec: ~>1.0
6
7
  sinatra: ~>1.1.0
@@ -1,5 +1,5 @@
1
1
  name: puggernaut
2
- version: 0.2.0
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
@@ -4,6 +4,7 @@ Puggernaut::Gems.activate %w(eventmachine em-websocket)
4
4
 
5
5
  require 'eventmachine'
6
6
  require 'em-websocket'
7
+ require 'memprof'
7
8
 
8
9
  $:.unshift File.dirname(__FILE__)
9
10
 
@@ -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
@@ -21,6 +21,8 @@ module Puggernaut
21
21
  logger.info "Server::Http#receive_data - Request - #{path} - #{query}"
22
22
  query = CGI.parse(query) if not query.nil?
23
23
  end
24
+
25
+ puts path
24
26
 
25
27
  if path == '/'
26
28
  channels, @join_leave, lasts, time, user_id = query_defaults(query)
@@ -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://" + window.location.host + ":" + webSocketPort() + "/");
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
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-03-15 00:00:00 -07:00
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: