Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (45 sloc) 1.267 kB
0efe2f7 @ddollar initial
ddollar authored
1 require "rubygems"
2 require "bundler/setup"
3
4 require "tweetstream"
43452d8 @rwdaigle Add use of resque queue
authored
5 require "resque"
bf5a79a @rwdaigle Add persistence and indexing of tweets
authored
6 require "resque/tasks"
43452d8 @rwdaigle Add use of resque queue
authored
7
bf5a79a @rwdaigle Add persistence and indexing of tweets
authored
8 require File.dirname(__FILE__) + "/jobs/push_tweet"
9 require File.dirname(__FILE__) + "/jobs/persist_tweet"
c3bc035 @ddollar sync logs
ddollar authored
10
0fce195 @rwdaigle Fix enqueuing
authored
11 STDOUT.sync = true
43452d8 @rwdaigle Add use of resque queue
authored
12
412f929 @rwdaigle Fix demo script command refs, logging output
authored
13
14 #-- Stream search results from twitter --#
15
bf5a79a @rwdaigle Add persistence and indexing of tweets
authored
16 task "tweetstream:stream" => "queue:environment" do
6457c47 @rwdaigle Try to fix Pusher.app_id setting
authored
17 TweetStream::Client.new(ENV["TWITTER_USERNAME"], ENV["TWITTER_PASSWORD"]).track(ENV["TWITTER_KEYWORD"]) do |status|
c1747d0 @rwdaigle Fix push tweet job dependencies
authored
18 puts "Received tweet: #{status[:text]}"
bf5a79a @rwdaigle Add persistence and indexing of tweets
authored
19 Resque.enqueue(PushTweet, status)
20 Resque.enqueue(PersistTweet, status)
0efe2f7 @ddollar initial
ddollar authored
21 end
22 end
3c64931 @rwdaigle Add clear queue rake task
authored
23
412f929 @rwdaigle Fix demo script command refs, logging output
authored
24
25 #-- Management/config --#
26
bf5a79a @rwdaigle Add persistence and indexing of tweets
authored
27 namespace :queue do
28
29 task :environment do
30 require File.dirname(__FILE__) + "/config/resque"
31 end
32
33 task :clear do
34 [:push, :persist].each do |name|
35 Resque.redis.del "queue:#{name}"
36 end
37 end
38 end
39
87f9619 @rwdaigle Attempt to fix pg connection issue in resque workers
authored
40 namespace :resque do
41
42 task :setup => "queue:environment" do
43 Resque.after_fork do |job|
f9a1310 @rwdaigle Fix background persistence
authored
44 if job.payload_class == PersistTweet
45 require File.dirname(__FILE__) + "/config/active_record"
46 end
87f9619 @rwdaigle Attempt to fix pg connection issue in resque workers
authored
47 end
48 end
49 end
50
bf5a79a @rwdaigle Add persistence and indexing of tweets
authored
51 namespace :db do
52
53 task :environment do
54 load 'config/active_record.rb'
55 end
56
57 desc "Migrate the database"
58 task(:migrate => :environment) do
59 ActiveRecord::Migrator.migrate("db/migrate")
60 end
3c64931 @rwdaigle Add clear queue rake task
authored
61 end
Something went wrong with that request. Please try again.