Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tcp_check.rake « gitlab « tasks « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4790d86832dc8ebbd94293b0b7a651e701b4d0f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

namespace :gitlab do
  desc "GitLab | Check TCP connectivity to a specific host and port"
  task :tcp_check, [:host, :port] => :environment do |_t, args|
    unless args.host && args.port
      puts "Please specify a host and port: `rake gitlab:tcp_check[example.com,80]`".color(:red)
      exit 1
    end

    checker = Gitlab::TcpChecker.new(args.host, args.port)

    if checker.check
      puts "TCP connection from #{checker.local} to #{checker.remote} succeeded".color(:green)
    else
      puts "TCP connection to #{checker.remote} failed: #{checker.error}".color(:red)
      puts
      puts 'Check that host and port are correct, and that the traffic is permitted through any firewalls.'
      exit 1
    end
  end
end