-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
50 lines (40 loc) · 1.17 KB
/
Rakefile
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
require 'resque/tasks'
require 'bundler/setup'
$: << File.join(File.dirname(__FILE__), 'lib')
require 'constructor'
task 'resque:setup' do
require 'environment'
end
namespace :tracer do
namespace :scene do
rule( /^dir:(.+)$/ => [proc { |task_name| task_name.sub(%r{[/:][^/]*$}, '') } ]) do |t, args|
dir = t.name.sub('dir:', '')
Dir.mkdir(dir) unless Dir.exists?(dir)
end
task :generate do
@view, @const_time = Constructor::generate
end
task :enqueue => :generate do
@job_id, @gen_time = Constructor::enqueue @view
end
task :start => [:enqueue, "dir:images/#{@job_id}"] do
p @job_id
File.open("images/#{@job_id}/log", 'w') do |log|
log << "Scene construction time: #{@construction_time}\n"
log << "Job generation time: #{@generation_time}\n"
end
end
end
namespace :workers do
task :setup do
ENV['COUNT'] = `grep -c "processor" /proc/cpuinfo`.strip
ENV['QUEUE'] = 'parts,jobs'
#ENV['VERBOSE'] = '1'
end
task :start => :setup do
puts "Spawning #{ENV['COUNT']} forks"
Rake::Task['resque:workers'].invoke
end
end
end
task :default => 'tracer:start'