Create deploy.rake
This task is to be run as a post-deploy script. It checks for new unimported data, imports it, then downloads the relevant images to S3 or local disk depending on the parameters provided.
This commit is contained in:
parent
93ee627771
commit
e05e19c266
1 changed files with 37 additions and 0 deletions
37
lib/tasks/deploy.rake
Normal file
37
lib/tasks/deploy.rake
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
namespace :deploy do
|
||||||
|
desc 'Post-deployment tasks: Import new data and download related images. Options: TEST=true for test mode, VERBOSE=true for verbose output, STORAGE=local|s3|both'
|
||||||
|
task post_deployment: :environment do
|
||||||
|
require_relative '../granblue/downloaders/base_downloader'
|
||||||
|
Dir[Rails.root.join('lib', 'granblue', '**', '*.rb')].each { |file| require file }
|
||||||
|
|
||||||
|
# Ensure Rails environment is loaded
|
||||||
|
Rails.application.eager_load!
|
||||||
|
|
||||||
|
# Parse and validate storage option
|
||||||
|
storage = (ENV['STORAGE'] || 'both').to_sym
|
||||||
|
unless [:local, :s3, :both].include?(storage)
|
||||||
|
puts 'Invalid STORAGE option. Must be one of: local, s3, both'
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
|
options = {
|
||||||
|
test_mode: ENV['TEST'] == 'true',
|
||||||
|
verbose: ENV['VERBOSE'] == 'true',
|
||||||
|
storage: storage
|
||||||
|
}
|
||||||
|
|
||||||
|
if options[:test_mode]
|
||||||
|
puts 'Test mode enabled'
|
||||||
|
end
|
||||||
|
|
||||||
|
if options[:verbose]
|
||||||
|
puts 'Verbose output enabled'
|
||||||
|
end
|
||||||
|
|
||||||
|
puts "Storage mode: #{storage}"
|
||||||
|
|
||||||
|
# Execute the task
|
||||||
|
manager = PostDeploymentManager.new(options)
|
||||||
|
manager.run
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue