Sha256: d179b3b13150c06846062245aa1c1361de4ba806d49ca688303c4491b4f4e2fb

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require "securerandom"

module Jets::Core
  class Booter
    class << self
      extend Memoist

      attr_reader :boot_at, :gid
      def boot!
        return false if @boot_at

        Jets::Bundle.require # require all the gems in the Gemfile
        require_config(:project) # for config.dotenv.overwrite

        if require_bootstrap?
          Jets::Dotenv.load!
          require_config(:bootstrap)
        end

        initialize!

        @gid = SecureRandom.uuid[0..7]
        @boot_at = Time.now.utc
      end

      def initialize!
        main = Jets::Autoloaders.main
        main.configure(Jets.root)
        main.setup
      end

      # Essentially deployment commands require the bootstrap to be run
      def require_bootstrap?
        args = ARGV.reject { |arg| arg.start_with?("-") }
        %w[
          bootstrap
          build
          delete
          deploy
          dockerfile
          release:rollback
        ].include?(args.last)
      end

      def require_config(name)
        files = [
          "config/jets/#{name}.rb",
          "config/jets/#{name}/#{Jets.env}.rb"
        ]
        files.each do |file|
          next unless File.exist?(file)
          require "#{Jets.root}/#{file}"
        end
      end
      memoize :require_config
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jets-6.0.5 lib/jets/core/booter.rb
jets-6.0.4 lib/jets/core/booter.rb
jets-6.0.3 lib/jets/core/booter.rb
jets-6.0.2 lib/jets/core/booter.rb