Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the behavior of remote_file #2

Open
slowjack2k opened this issue May 6, 2014 · 2 comments
Open

Change the behavior of remote_file #2

slowjack2k opened this issue May 6, 2014 · 2 comments

Comments

@slowjack2k
Copy link

I like to suggest to Introduce first a RoleTask. With this in place you can do this (only a thought not tested):

role :web 

remote_file 'my/path/text.txt' => ['local/file.txt', :web, :all] do |task|
    roles = t.prerequisites.find_all{ Rake::Task[name].class == RoleTask}
    on roles do
        .... upload the file
    end
end 

And with a RemoteFileTask

  class RemoteFileTask < FileTask
    # pseudo code
     def needed?
      ! File.exist_on_every_remote_host?(name) || out_of_date?(timestamp) ||        @application.options.build_all
    end

    # Time stamp for file task.
    def timestamp
      if File.exist_remote_on_all_roles?(name)
        sanatize_time(File.earliest_mtime_remote(name.to_s))
      else
        Rake::EARLY
      end
    end

    def  sanatize_time(time)
        if option_trust_time
           time
        else
            get_earliest_time_on_remote_hosts_diff_to_local_time(time)
        end
    end

    private

    # has to be changed
    def out_of_date?(stamp)
      @prerequisites.any? { |n| application[n, @scope].timestamp > stamp }
    end
  end
@leehambley
Copy link
Member

out_of_date?(timestamp)

This will cause unending problems, which is why we haven't done it.

And I don't believe that your suggestions (get_earliest_time_on_remote_hosts_diff_to_local_time) will really work, but I would love them to.

@slowjack2k
Copy link
Author

And I don't believe that your suggestions (get_earliest_time_on_remote_hosts_diff_to_local_time) will really work, but I would love them to.

Can you please explain your concerns?

Do you think a time_diff_host_1 = 'ssh date -u' - Time.local.utc , time_diff_host_2 = 'ssh date -u' - Time.local.utc and so on is not sufficient? The drifft should be max 1 second I think. And when some one does not want to setup a time server to sync time then this approach should be ok. If the user has a timeserver and sets the options we trust the remote time and caluclate no diff.

After the file creation you have to touch the files on all servers and set the same timestamp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants