class Falcon::Command::Virtual
def assume_privileges(path)
def assume_privileges(path) stat = File.stat(path) Process::GID.change_privilege(stat.gid) Process::UID.change_privilege(stat.uid) home = Etc.getpwuid(stat.uid).dir return { 'HOME' => home, } end
def call
def call container = run(parent.verbose?) container.wait end
def host_endpoint(hostname, **options)
def host_endpoint(hostname, **options) endpoint = secure_endpoint(**options) url = URI.parse(@options[:bind_secure]) url.hostname = hostname return Async::HTTP::Endpoint.new(url, hostname: endpoint.hostname) end
def insecure_endpoint(**options)
def insecure_endpoint(**options) Async::HTTP::Endpoint.parse(@options[:bind_insecure], **options) end
def run(verbose = false)
def run(verbose = false) configuration = Configuration.new(verbose) container = Async::Container.new @paths.each do |path| path = File.expand_path(path) root = File.dirname(path) configuration.load_file(path) spawn(path, container, chdir: root) end hosts = Hosts.new(configuration) hosts.run(container, **@options) return container end
def secure_endpoint(**options)
def secure_endpoint(**options) Async::HTTP::Endpoint.parse(@options[:bind_secure], **options) end
def spawn(path, container, **options)
def spawn(path, container, **options) container.spawn(name: self.name, restart: true) do |instance| env = assume_privileges(path) instance.exec(env, "bundle", "exec", path, **options) end end