Class: Portless::Multi
- Inherits:
-
Object
- Object
- Portless::Multi
- Defined in:
- lib/portless/multi.rb
Overview
Run several apps under one proxy, each at its own <name>.<tld>, from the
apps map in portless.json. Every app gets a free backend port, a route, and
injected PORT/HOST/PORTLESS_URL; all run in their own process groups and are
supervised + torn down together. Ruby sets env per-spawn, so there's no
NODE_OPTIONS loader hack (cf. portless's turbo.ts).
Defined Under Namespace
Classes: App
Instance Method Summary collapse
-
#initialize(config: Config.load, route_store: RouteStore.new) ⇒ Multi
constructor
A new instance of Multi.
- #run ⇒ Object
Constructor Details
#initialize(config: Config.load, route_store: RouteStore.new) ⇒ Multi
Returns a new instance of Multi.
12 13 14 15 16 |
# File 'lib/portless/multi.rb', line 12 def initialize(config: Config.load, route_store: RouteStore.new) @config = config @route_store = route_store @apps = [] end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/portless/multi.rb', line 18 def run raise Error, "no apps defined — add an \"apps\" map to portless.json" if @config.apps.empty? ensure_trusted if @config.tls proxy_port = Daemon.ensure_running(tls: @config.tls) @apps = @config.apps.map { |name, command| start_app(name, command, proxy_port) } Banner.multi(apps: @apps) install_signal_handlers Process.waitall ensure teardown end |