Class: Falcon::Command::Virtual
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Virtual
- Defined in:
- lib/falcon/command/virtual.rb
Instance Method Summary collapse
- #assume_privileges(path) ⇒ Object
- #call ⇒ Object
- #insecure_endpoint ⇒ Object
- #run(verbose = false) ⇒ Object
- #secure_endpoint ⇒ Object
- #spawn(path, container, **options) ⇒ Object
Instance Method Details
#assume_privileges(path) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/falcon/command/virtual.rb', line 50 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 |
#call ⇒ Object
90 91 92 93 94 |
# File 'lib/falcon/command/virtual.rb', line 90 def call container = run(parent.verbose?) container.wait end |
#insecure_endpoint ⇒ Object
96 97 98 |
# File 'lib/falcon/command/virtual.rb', line 96 def insecure_endpoint Async::HTTP::Endpoint.parse([:bind_insecure]) end |
#run(verbose = false) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/falcon/command/virtual.rb', line 71 def run(verbose = false) configuration = Configuration.new(verbose) container = Async::Container.new @paths.each do |path| path = File.(path) root = File.dirname(path) configuration.load_file(path) spawn(path, container, chdir: root) end hosts = Hosts.new(configuration) hosts.run(container, **) return container end |
#secure_endpoint ⇒ Object
100 101 102 |
# File 'lib/falcon/command/virtual.rb', line 100 def secure_endpoint Async::HTTP::Endpoint.parse([:bind_secure]) end |
#spawn(path, container, **options) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/falcon/command/virtual.rb', line 63 def spawn(path, container, **) container.spawn(name: self.name, restart: true) do |instance| env = assume_privileges(path) instance.exec(env, "bundle", "exec", path, **) end end |