diff options
author | Nick Thomas <nick@gitlab.com> | 2017-12-06 09:39:25 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-12-13 15:53:32 +0000 |
commit | ab4fa64308176cc069e6a731d35a53c886af805e (patch) | |
tree | 09d0c5d8a1a50abe3aa1aef418407b3379d3d2ec /lib/tasks | |
parent | 8ff63039f1ee5f6e31a8b910e323977e7de3c634 (diff) | |
download | gitlab-ce-ab4fa64308176cc069e6a731d35a53c886af805e.tar.gz |
Add a gitlab:tcp_check rake task
This allows us to avoid relying on telnet / netcat being installed
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/gitlab/tcp_check.rake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/tcp_check.rake b/lib/tasks/gitlab/tcp_check.rake new file mode 100644 index 00000000000..1400f57d6b9 --- /dev/null +++ b/lib/tasks/gitlab/tcp_check.rake @@ -0,0 +1,20 @@ +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 |