This repository was archived by the owner on Apr 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathRakefile.rb
53 lines (51 loc) · 2.08 KB
/
Rakefile.rb
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
task :environment
PathUser = "#{File.dirname(__FILE__)}/../config/userdata.json".freeze
PathConfig = "#{File.dirname(__FILE__)}/../config/config.yml".freeze
PathIni = "#{File.dirname(__FILE__)}/../config/moviemasher.ini".freeze
namespace :moviemasher do
desc "Creates service and calls its init method, saving result to #{PathUser}"
task :init, :service_id, :config_path, :user_config_path do |_t, args|
service_id = args[:service_id]
if service_id.to_s.empty?
puts "#{Time.now} moviemasher:init no service_id parameter provided"
else
require_relative 'lib/moviemasher'
MovieMasher.configure(args[:config_path] || PathConfig)
MovieMasher.configure(args[:user_config_path] || PathUser)
init_service = MovieMasher::Service.initer(service_id)
if init_service
puts "#{Time.now} moviemasher:init '#{service_id}' starting..."
parsed = init_service.init
if parsed
File.open(PathUser, 'w') { |f| f.write(parsed.to_json) }
puts "#{Time.now} saved JSON user data to #{PathUser}"
end
end
puts "#{Time.now} moviemasher:init '#{service_id}' completed"
end
end
desc 'Checks SQS and directory queues'
task :process_queues, :config_path, :user_config_path do |_t, args|
require_relative 'lib/moviemasher'
MovieMasher.configure(args[:config_path] || PathConfig)
MovieMasher.configure(args[:user_config_path] || PathUser)
puts "#{Time.now} moviemasher:process_queues called"
STDOUT.flush
dir = MovieMasher.configuration[:render_directory]
stop_file = MovieMasher::Path.concat(dir, 'disable_process_queues.txt')
if File.exist?(stop_file)
puts "#{Time.now} moviemasher:process_queues aborted - stop file found"
else
begin
File.open(stop_file, 'w') {}
MovieMasher.process_queues
rescue StandardError => e
puts "#{Time.now} moviemasher:process_queues caught #{e.message}"
raise
ensure
puts "#{Time.now} moviemasher:process_queues completed"
File.delete(stop_file) if File.exist?(stop_file)
end
end
end
end