Class: Everywhere::Framework::Rails

Inherits:
Framework
  • Object
show all
Defined in:
lib/everywhere/framework.rb

Overview

---- build/dev (CLI side) ------------------------------------------------

Instance Method Summary collapse

Instance Method Details

#boot!(port:) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/everywhere/framework.rb', line 158

def boot!(port:)
  # Normally defined by bin/rails; the server command requires it.
  ::Object.const_set(:APP_PATH, File.join(root, "config/application")) unless defined?(::APP_PATH)
  # native_boot.rb requires this gem BEFORE Rails exists, so the engine
  # guard in everywhere.rb saw no ::Rails::Engine — and Bundler.require
  # won't re-require an already-loaded gem when the app boots below.
  # Without this, packaged apps silently lose the engine (bridge asset
  # path + "@rubyeverywhere/bridge" importmap pin).
  unless defined?(Everywhere::Engine)
    require "rails" # rails/engine alone lacks the AS core_ext it uses
    require "rails/engine"
    require_relative "engine"
  end
  require File.join(root, "config/environment")
  Everywhere::Database.prepare!(root)

  require "rails/command"
  ::Rails::Command.invoke :server, ["--binding=127.0.0.1", "--port=#{port}"]
end

#boot_stubObject

Rails loads its bundle through config/boot.rb (with bootsnap guarded).



182
183
184
# File 'lib/everywhere/framework.rb', line 182

def boot_stub
  render_boot_stub(env_exports, "require_relative \"config/boot\"")
end

#cleanup_commandObject



150
# File 'lib/everywhere/framework.rb', line 150

def cleanup_command = "bin/rails assets:clobber"

#dev_commandObject

CLI executable?, not exist?: a repo downloaded as a zip loses the exec bit, and running bin/dev then dies with a bare "Permission denied".



140
141
142
# File 'lib/everywhere/framework.rb', line 140

def dev_command
  File.executable?(File.join(root, "bin", "dev")) ? "bin/dev" : "bundle exec rails server"
end

#env_exportsObject

Install



179
# File 'lib/everywhere/framework.rb', line 179

def env_exports = { "RAILS_ENV" => "production" }

#nameObject



135
# File 'lib/everywhere/framework.rb', line 135

def name = "rails"

#precompile_commandObject



148
# File 'lib/everywhere/framework.rb', line 148

def precompile_command = "bin/rails assets:precompile"

#precompile_envObject



144
145
146
# File 'lib/everywhere/framework.rb', line 144

def precompile_env
  { "RAILS_ENV" => "production", "SECRET_KEY_BASE" => "precompile-only" }
end

#prepare_runtime_envObject

Runtime



153
154
155
156
# File 'lib/everywhere/framework.rb', line 153

def prepare_runtime_env
  ENV["RAILS_ENV"] ||= "production"
  ENV["SOLID_QUEUE_IN_PUMA"] ||= "1"
end