Sha256: b87144df5223a2f340a42a66444ba004bbb51ad83a3e8a85258164b440b868f2

Contents?: true

Size: 821 Bytes

Versions: 39

Compression:

Stored size: 821 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_migrations.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

39 entries across 25 versions & 7 rubygems

Version Path
muck-activities-3.2.2 test/lib/daemons/amazonaws.rb
uploader-3.1.4 test/rails_test/lib/daemons/amazonaws.rb
uploader-3.1.4 lib/daemons/amazonaws.rb
uploader-3.1.3 test/rails_test/lib/daemons/amazonaws.rb
uploader-3.1.3 lib/daemons/amazonaws.rb
uploader-3.1.2 test/rails_test/lib/daemons/amazonaws.rb
uploader-3.1.2 lib/daemons/amazonaws.rb
uploader-3.1.1 lib/daemons/amazonaws.rb
uploader-3.1.1 test/rails_test/lib/daemons/amazonaws.rb
uploader-3.1.0 test/rails_test/lib/daemons/amazonaws.rb
uploader-3.1.0 lib/daemons/amazonaws.rb
muck-activities-3.2.1 test/lib/daemons/amazonaws.rb
muck-services-3.3.3 test/lib/daemons/amazonaws.rb
muck-commerce-3.0.1 test/lib/daemons/amazonaws.rb
muck-profiles-3.1.4 test/lib/daemons/amazonaws.rb
muck-auth-3.5.4 test/lib/daemons/amazonaws.rb
muck-auth-3.5.3 test/lib/daemons/amazonaws.rb
muck-profiles-3.1.3 test/lib/daemons/amazonaws.rb
muck-auth-3.5.2 test/lib/daemons/amazonaws.rb
muck-invites-3.4.1 test/lib/daemons/amazonaws.rb