This repository was archived by the owner on Feb 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
65 lines (53 loc) · 1.51 KB
/
Rakefile
File metadata and controls
65 lines (53 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'bundler/setup'
Bundler.require :default
require 'resque/tasks'
require 'rake/testtask'
$:.unshift File.join File.dirname(__FILE__), 'lib'
task :default => :test
task :test do
Rake::TestTask.new do |t|
require 'turn/autorun'
t.libs.push "lib"
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end
end
def redis_connection(url)
uri = URI.parse(url || 'redis://localhost:6379/')
Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end
task "resque:setup" do
Bundler.require(:worker)
require 'models'
require 'brain'
require 'prism/back/funpack'
require 'jobs'
require 'json'
$redis = redis_connection(ENV['PARTY_CLOUD_REDIS'])
Resque.redis = redis_connection(ENV['MINEFOLD_REDIS'])
$mongo = begin
uri = ENV['MONGO_URL'] || 'mongodb://localhost:27017/minefold_development'
mongo = ::Mongo::Connection.from_uri(uri)
if mongo.is_a? ::Mongo::MongoReplicaSetClient
# this should be in the damn ruby driver
mongo_uri = ::Mongo::URIParser.new(uri)
auth = mongo_uri.auths.first
db = mongo[auth[:db_name]]
db.authenticate auth[:username], auth[:password]
db
else
db_name = mongo.auths.any? ? mongo.auths.first[:db_name] : nil
db_name ||= URI.parse(uri).path[1..-1]
mongo[db_name]
end
end
end
namespace :funpack do
task :start do
redis_connection.lpush "servers:requests:start", JSON.dump(
server_id: ENV['SERVER'],
funpack_id: ENV['FUNPACK'],
data: '',
)
end
end