Class: Jets::Core::Booter

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/core/booter.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.boot_atObject (readonly)

Returns the value of attribute boot_at.



8
9
10
# File 'lib/jets/core/booter.rb', line 8

def boot_at
  @boot_at
end

.gidObject (readonly)

Returns the value of attribute gid.



8
9
10
# File 'lib/jets/core/booter.rb', line 8

def gid
  @gid
end

Class Method Details

.boot!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jets/core/booter.rb', line 9

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

.initialize!Object



26
27
28
29
30
# File 'lib/jets/core/booter.rb', line 26

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

.require_bootstrap?Boolean

Essentially deployment commands require the bootstrap to be run

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jets/core/booter.rb', line 33

def require_bootstrap?
  args = ARGV.reject { |arg| arg.start_with?("-") }
  %w[
    bootstrap
    build
    delete
    deploy
    dockerfile
    release:rollback
  ].include?(args.last)
end

.require_config(name) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/jets/core/booter.rb', line 45

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