suj-pusher 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -133,8 +133,11 @@ msg_json = MultiJson.dump(msg)
133
133
  # Obtain a redis instance
134
134
  redis = Redis.new({ host: "localhost", port: 6379})
135
135
 
136
- # Push the message to the *suj_pusher_queue* in the redis server.
137
- redis.publish "suj_pusher_queue", msg_json
136
+ # Push the message to the *suj_pusher_queue* in the redis server:
137
+ redis.lpush "suj_pusher_msgs", msg_json
138
+
139
+ # Notify workers there is a new message
140
+ redis.publish "suj_pusher_queue", "PUSH_MSG"
138
141
  ```
139
142
 
140
143
  You must push the messages to the *suj_pusher_queue* queue that is the one the Pusher daemon is listening to. Also make sure your message follows the format described on the previous sections.
data/bin/pusher CHANGED
@@ -11,21 +11,6 @@ WORKDIR = Dir.pwd
11
11
 
12
12
  class PusherDaemon < DaemonSpawn::Base
13
13
  def start(args)
14
- config = Suj::Pusher::Configuration.new
15
- args.options do |opts|
16
- opts.banner = BANNER
17
- opts.on('-r REDIS', '--redis REDIS', String, 'Redis server to connect') { |redis| config.redis = redis }
18
- opts.on('-v', '--version', 'Print this version of rapns.') { puts "rapns #{Suj::Pusher::VERSION}"; exit }
19
- opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
20
- opts.parse!
21
- end
22
-
23
- config.certs_path = File.join(WORKDIR, "certs")
24
- FileUtils.mkdir_p(config.certs_path)
25
- FileUtils.mkdir_p(File.join(WORKDIR, "logs"))
26
- FileUtils.mkdir_p(File.join(WORKDIR, "tmp/pids"))
27
- Suj::Pusher.config.update(config)
28
-
29
14
  @daemon = Suj::Pusher::Daemon.new
30
15
  @daemon.start
31
16
  end
@@ -35,7 +20,34 @@ class PusherDaemon < DaemonSpawn::Base
35
20
  end
36
21
  end
37
22
 
23
+ redis = "redis://localhost:6379/pusher"
24
+ logdir = File.join(WORKDIR, "logs")
25
+ piddir = File.join(WORKDIR, "pids")
26
+ cerdir = File.join(WORKDIR, "certs")
27
+
28
+ ARGV.options do |opts|
29
+ opts.banner = BANNER
30
+ opts.on('-r REDIS', '--redis REDIS', String, 'Redis server to connect') { |r|redis = r }
31
+ opts.on('-l LOGS', '--logdir LOGS', String, 'Logs destination directory') { |l| logdir = l }
32
+ opts.on('-p PIDS', '--piddir PIDS', String, 'Pids destination diercoty') { |pid| piddir = pid }
33
+ opts.on('-c CERTS', '--cerdir CERTS', String, 'Directory to store certificates') { |cert| cerdir = cert }
34
+ opts.on('-v', '--version', 'Print this version of pusher daemon.') { puts "rapns #{Suj::Pusher::VERSION}"; exit }
35
+ opts.on('-h', '--help', 'You\'re looking at it.') { puts opts; exit }
36
+ opts.parse!
37
+ end
38
+
39
+ FileUtils.mkdir_p(cerdir)
40
+ FileUtils.mkdir_p(logdir)
41
+ FileUtils.mkdir_p(piddir)
42
+
43
+ config = Suj::Pusher::Configuration.new
44
+ config.certs_path = cerdir
45
+ config.redis = redis
46
+ Suj::Pusher.config.update(config)
47
+
38
48
  PusherDaemon.spawn!(
39
49
  sync_log: true,
40
- working_dir: Dir.pwd
50
+ working_dir: Dir.pwd,
51
+ log_file: File.join(logdir, "pusher-worker.log"),
52
+ pid_file: File.join(piddir, "pusher-worker.pid")
41
53
  )
@@ -15,6 +15,7 @@ module Suj
15
15
 
16
16
  def start
17
17
  info "Starting pusher daemon"
18
+ info " subsribe to push messages from #{Suj::Pusher.config.redis}"
18
19
  EM.run do
19
20
  wait_msg do |msg|
20
21
  begin
@@ -1,5 +1,5 @@
1
1
  module Suj
2
2
  module Pusher
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,20 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suj-pusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Horacio Sanson
9
- - Fernando Wong
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-10-10 00:00:00.000000000 Z
12
+ date: 2013-10-11 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: em-http-request
17
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &24896380 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,15 +21,10 @@ dependencies:
22
21
  version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '0'
24
+ version_requirements: *24896380
31
25
  - !ruby/object:Gem::Dependency
32
26
  name: em-hiredis
33
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &24895960 !ruby/object:Gem::Requirement
34
28
  none: false
35
29
  requirements:
36
30
  - - ! '>='
@@ -38,15 +32,10 @@ dependencies:
38
32
  version: '0'
39
33
  type: :runtime
40
34
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
35
+ version_requirements: *24895960
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: multi_json
49
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &24895540 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ! '>='
@@ -54,15 +43,10 @@ dependencies:
54
43
  version: '0'
55
44
  type: :runtime
56
45
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
46
+ version_requirements: *24895540
63
47
  - !ruby/object:Gem::Dependency
64
48
  name: daemon-spawn
65
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &24895120 !ruby/object:Gem::Requirement
66
50
  none: false
67
51
  requirements:
68
52
  - - ! '>='
@@ -70,12 +54,7 @@ dependencies:
70
54
  version: '0'
71
55
  type: :runtime
72
56
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0'
57
+ version_requirements: *24895120
79
58
  description: Stand alone push notification server for APN and GCM.
80
59
  email:
81
60
  - rd@skillupjapan.co.jp
@@ -118,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
97
  version: '0'
119
98
  requirements: []
120
99
  rubyforge_project:
121
- rubygems_version: 1.8.23
100
+ rubygems_version: 1.8.12
122
101
  signing_key:
123
102
  specification_version: 3
124
103
  summary: Stand alone push notification server.