Sha256: f7b5bb82c129aea8290e82e8e5b16097c3598edd8be2156db113aa4cbfa3e86f
Contents?: true
Size: 1.14 KB
Versions: 15
Compression:
Stored size: 1.14 KB
Contents
class PerformTaskJob < BackgroundJob queue_as :deploys def perform(task) @task = task @commands = Commands.for(@task) unless @task.pending? logger.error("Task ##{@task.id} already in `#{@task.status}` state. Aborting.") return end run ensure @task.clear_working_directory end def run @task.run! checkout_repository perform_task @task.complete! rescue Command::Error => error @task.report_failure!(error) rescue StandardError => error @task.report_error!(error) end def perform_task Bundler.with_clean_env do capture_all @commands.install_dependencies capture_all @commands.perform end end def checkout_repository @task.acquire_git_cache_lock do capture @commands.fetch capture @commands.clone end capture @commands.checkout(@task.until_commit) end def capture_all(commands) commands.map { |c| capture(c) } end def capture(command) command.start @task.write("$ #{command}\npid: #{command.pid}\n") @task.pid = command.pid command.stream! do |line| @task.write(line) end @task.write("\n") end end
Version data entries
15 entries across 15 versions & 1 rubygems