Sha256: 083b0902f5a2dd97b2f8ef21fe14009d0f726821d4ddd59df5ae3c9f7e9e871a
Contents?: true
Size: 820 Bytes
Versions: 77
Compression:
Stored size: 820 Bytes
Contents
#!/usr/bin/env ruby # You might want to change this ENV["RAILS_ENV"] ||= "production" require File.dirname(__FILE__) + "/../../config/environment" $running = true Signal.trap("TERM") do $running = false end # Waiting is a timer variable to allow the daemon to restart # within two seconds of the Signal rather than using a long # sleep command and forcing the daemon to wait. $waiting = 0 ActiveRecord::Base.logger.info "[AmazonS3] Migration daemon started at #{Time.now}.\n" while($running) do if $waiting < 120 $waiting += 2 sleep 2 else $waiting = 0 upload = Upload.pending_s3_migration.first if upload $waiting = 120 - 2 ActiveRecord::Base.logger.info "[AmazonS3] Migrating upload ##{upload.id}\n" upload.remote = upload.local upload.save! end end end
Version data entries
77 entries across 68 versions & 5 rubygems