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)
end

def call

def call
	container = run(parent.verbose?)
	
	container.wait
end

def insecure_endpoint

def insecure_endpoint
	Async::HTTP::Endpoint.parse(@options[:bind_insecure])
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

def secure_endpoint
	Async::HTTP::Endpoint.parse(@options[:bind_secure])
end

def spawn(path, container, **options)

def spawn(path, container, **options)
	container.spawn(name: self.name, restart: true) do |instance|
		assume_privileges(path)
		
		instance.exec("bundle", "exec", path, **options)
	end
end