This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRakefile
80 lines (69 loc) · 2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
require 'rspec/core/rake_task'
require 'ci/reporter/rake/rspec'
$stdout.sync = true # gives foreman full stdout
task :default => :help
desc "Show help menu"
task :help do
puts "Available rake tasks: "
puts "rake console - Run a IRB console with all enviroment loaded"
puts "rake spec - Run specs and calculate coverage"
end
desc "Run specs"
task :spec do
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = './spec/**/*_spec.rb'
end
end
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task["spec"].execute
end
desc "Run CI rspec"
task "ci_rspec" => ["ci:setup:rspec", "^spec"]
desc "Run IRB console with app environment"
task :console do
puts "Loading development console..."
system("irb -r ./api.rb")
end
desc "Starts the Scheduler worker"
task :scheduler do
require File.join(File.dirname(__FILE__), 'lib', 'rules.rb')
scheduler.join
end
desc "activates all saved schedules and scheduled rules if Scheduler is restarted and in production mode"
task :load_activated_schedules do
require File.join(File.dirname(__FILE__), 'config', 'init.rb')
t = Thread.new do
puts "waiting 5 sec before activating schedules..."
sleep(5)
Scheduler = DRbObject.new_with_uri DRBSERVER
begin
### activate library OAI schedules ###
Library.all.each do |library|
next unless library.oai["schedule"]
unless library.oai["schedule"].empty?
Scheduler.schedule_oai_harvest(:id => library.id)
puts "Activating OAI scheduled harvest: #{library.name}"
end
end
rescue Exception => e
puts "error #{e}"
end
begin
### activate scheduled global Rules ###
Rule.all.each do |rule|
if not rule.frequency.empty? and rule.type == "global"
rule.globalize
rule.sanitize
puts "Activating scheduled rule: #{rule.name}"
Scheduler.schedule_isql_rule(rule)
end
end
rescue Exception => e
puts "error #{e}"
end
puts "...done"
sleep()
end
t.join
end