Skip to content

Commit

Permalink
Allow to configure static file server
Browse files Browse the repository at this point in the history
  • Loading branch information
rsamoilov committed Aug 18, 2024
1 parent 7858743 commit 84baf2d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/rage/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ def server
app = ::Rack::Builder.parse_file(options[:config] || "config.ru")
app = app[0] if app.is_a?(Array)

port = options[:port] || Rage.config.server.port
address = options[:binding] || (Rage.env.production? ? "0.0.0.0" : "localhost")
timeout = Rage.config.server.timeout
max_clients = Rage.config.server.max_clients
server_options = { service: :http, handler: app }

::Iodine.listen service: :http, handler: app, port: port, address: address, timeout: timeout, max_clients: max_clients
server_options[:port] = options[:port] || Rage.config.server.port
server_options[:address] = options[:binding] || (Rage.env.production? ? "0.0.0.0" : "localhost")
server_options[:timeout] = Rage.config.server.timeout
server_options[:max_clients] = Rage.config.server.max_clients
server_options[:public] = Rage.config.public_file_server.enabled ? Rage.root.join("public").to_s : nil

::Iodine.listen(**server_options)
::Iodine.threads = Rage.config.server.threads_count
::Iodine.workers = Rage.config.server.workers_count

Expand Down
8 changes: 8 additions & 0 deletions lib/rage/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ def cable
@cable ||= Cable.new
end

def public_file_server
@public_file_server ||= PublicFileServer.new
end

def internal
@internal ||= Internal.new
end
Expand Down Expand Up @@ -246,6 +250,10 @@ def middlewares
end
end

class PublicFileServer
attr_accessor :enabled
end

# @private
class Internal
attr_accessor :rails_mode
Expand Down

0 comments on commit 84baf2d

Please sign in to comment.