summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-02-02 21:49:15 -0700
committermo khan <mo@mokhan.ca>2015-02-02 21:49:15 -0700
commita5b223df0605b6c46321fcf1dc21108e1ab8b0f2 (patch)
tree5241db064c0906c0717fbe1dfbacedb994dea7a1
parentb43701e165fcc7e76110e5ae51040fbb5d34a30e (diff)
add sneakers worker.
-rw-r--r--Procfile2
-rw-r--r--Rakefile1
-rw-r--r--app/workers/events_worker.rb9
-rw-r--r--config/initializers/sneakers.rb2
4 files changed, 14 insertions, 0 deletions
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..10c91ff
--- /dev/null
+++ b/Procfile
@@ -0,0 +1,2 @@
+web: rails s
+worker: env WORKERS=EventsWorker rake sneakers:run
diff --git a/Rakefile b/Rakefile
index ba6b733..f6490d7 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,5 +2,6 @@
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
+require 'sneakers/tasks'
Rails.application.load_tasks
diff --git a/app/workers/events_worker.rb b/app/workers/events_worker.rb
new file mode 100644
index 0000000..23c7225
--- /dev/null
+++ b/app/workers/events_worker.rb
@@ -0,0 +1,9 @@
+class EventsWorker
+ include Sneakers::Worker
+ from_queue "dashboard.events", env: nil
+
+ def work(raw_post)
+ Event.create!(raw_post)
+ ack! # we need to let queue know that message was received
+ end
+end
diff --git a/config/initializers/sneakers.rb b/config/initializers/sneakers.rb
new file mode 100644
index 0000000..c3e288c
--- /dev/null
+++ b/config/initializers/sneakers.rb
@@ -0,0 +1,2 @@
+Sneakers.configure({})
+Sneakers.logger.level = Logger::INFO