Sha256: 9bb101f51cfe6360948a658172fda9e52a8c4d1a3937a511bbd4f550371aba46

Contents?: true

Size: 1.28 KB

Versions: 29

Compression:

Stored size: 1.28 KB

Contents

# encoding: utf-8
require 'mutx'
require 'sidetiq'
require 'open-uri'
#require 'sidekiq/testing/inline'

module Mutx
  module Workers
    class ConnectivityCheck
      include Sidekiq::Worker
      include Sidetiq::Schedulable
        recurrence { minutely(2) }
        def perform
        #def self.check
          #Mutx::Database::MongoConnector.new Mutx::Support::Configuration.db_connection_data
          path = "#{Dir.pwd}/mutx/temp/connectivity_check.txt"
          message_lost = "Internet connection lost!"
          begin
            if open("http://www.google.com/")
              puts "HAY INTERNET..."
              contents = File.read("#{path}") if File.file?("#{path}")
              Mutx::Support::MailSender.new.sender(nil, "No internet connection for a while, now is ready again", "ohamra@gmail.com", "Prueba", nil, nil, nil, nil, nil) if ( (!contents.nil?) && (contents.include? "#{message_lost}") )
              File.delete("#{path}") if File.file?("#{path}")
            else
              raise StandardError.new "#{message_lost}"
            end
          rescue StandardError => e
            output = File.open("#{path}", "a+")
            text = "#{Time.now} - #{e.message}"
            output.puts "#{text}"
            output.close
          end
        end
    end#class
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
mutx-0.2.7 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.6 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.5 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.4 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.3 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.2 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.1 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.2.0 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.69 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.68 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.67 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.66 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.65 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.64 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.63 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.62 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.61 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.60 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.59 lib/mutx/background_jobs/workers/connectivity_check.rb
mutx-0.1.58 lib/mutx/background_jobs/workers/connectivity_check.rb