<commit_before>namespace :deploy do

  task :status do |t|
    require 'open-uri'
    system("git fetch -q")
    protocol = fetch(:protocol, 'http')
    port = fetch(:port, 80)
    on roles(:app) do |host|
      addr = "#{protocol}://#{host}:#{port}/deploy_status"
      open(addr, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
        status = f.read.gsub("\n","")
        branch = fetch(:branch, 'HEAD')
        remote_commit = status.split('|').first.split[1]
        local_commit = %x(git rev-parse --short origin/#{branch.to_s.shellescape})
        puts "#{host} runs: #{remote_commit}, should run: #{branch}@#{local_commit}"<commit_msg>Raise error if deploy:status gives different versions<commit_after>namespace :deploy do

  task :status do |t|
    require 'open-uri'
    system("git fetch -q")
    protocol = fetch(:protocol, 'http')
    port = fetch(:port, 80)
    on roles(:app) do |host|
      addr = "#{protocol}://#{host}:#{port}/deploy_status"
      open(addr, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
        status = f.read.gsub("\n","")
        branch = fetch(:branch, 'HEAD')
        remote_commit = status.split('|').first.split[1]
        local_hash = %x(git rev-parse --short origin/#{branch.to_s.shellescape}).strip
        local_commit = "#{branch}@#{local_hash}"
        puts "#{host} runs: #{remote_commit}, should run: #{local_commit}"
        if remote_commit != local_commit
          fail "Wrong commit is running, you should probably restart unicorn"
        end
{'fraction_non_alphanumeric': 0.16644562334217505, 'fraction_numerical': 0.003978779840848806, 'mean_word_length': 3.2869318181818183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3091645', 'n_tokens_mistral': 488, 'n_tokens_neox': 484, 'n_words': 117}