summaryrefslogtreecommitdiff
path: root/lib/gitlab/console.rb
blob: c3c34bb0f61a2e86545a725d8f72570ca0ee2504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

# rubocop:disable Rails/Output
module Gitlab
  module Console
    class << self
      def welcome!
        return unless Gitlab::Runtime.console?

        # note that this will not print out when using `spring`
        justify = 15

        puts '-' * 80
        puts " Ruby:".ljust(justify) + RUBY_DESCRIPTION
        puts " GitLab:".ljust(justify) + "#{Gitlab::VERSION} (#{Gitlab.revision}) #{Gitlab.ee? ? 'EE' : 'FOSS'}"
        puts " GitLab Shell:".ljust(justify) + "#{Gitlab::VersionInfo.parse(Gitlab::Shell.version)}"

        if ApplicationRecord.database.exists?
          puts " #{ApplicationRecord.database.human_adapter_name}:".ljust(justify) + ApplicationRecord.database.version

          Gitlab.ee do
            if Gitlab::Geo.connected? && Gitlab::Geo.enabled?
              puts " Geo enabled:".ljust(justify) + 'yes'
              puts " Geo server:".ljust(justify) + EE::GeoHelper.current_node_human_status
            end
          end
        end

        if RUBY_PLATFORM.include?('darwin')
          # Sorry, macOS users. The current implementation requires procfs.
          puts '-' * 80
        else
          boot_time_seconds = Gitlab::Metrics::BootTimeTracker.instance.startup_time
          booted_in = "[ booted in %.2fs ]" % [boot_time_seconds]
          puts '-' * (80 - booted_in.length) + booted_in
        end
      end
    end
  end
end
# rubocop:enable Rails/Output