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

Version Path
jbasdf-uploader-0.1.8 lib/daemons/amazonaws.rb
uploader-0.2.8 test/rails_root/lib/daemons/amazonaws.rb
uploader-0.2.8 lib/daemons/amazonaws.rb
muck-contents-0.2.27 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.26 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.2.4 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.2.3 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.25 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.24 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.23 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.2.2 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.22 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.21 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.2.1 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.2.0 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.20 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.1.11 test/rails_root/lib/daemons/amazonaws.rb
muck-contents-0.2.18 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.1.9 test/rails_root/lib/daemons/amazonaws.rb
muck-oauth-0.1.8 test/rails_root/lib/daemons/amazonaws.rb