Class: Ruby::Nginx::Commands::StartNginx
- Inherits:
-
TerminalCommand
- Object
- TerminalCommand
- Ruby::Nginx::Commands::StartNginx
- Defined in:
- lib/ruby/nginx/commands/start_nginx.rb
Instance Attribute Summary
Attributes inherited from TerminalCommand
#cmd, #error_type, #printer, #result, #user
Instance Method Summary collapse
-
#initialize(sudo: false) ⇒ StartNginx
constructor
A new instance of StartNginx.
- #run ⇒ Object
Methods included from Helpers::SudoHelper
Methods included from Helpers::PromptHelper
Constructor Details
#initialize(sudo: false) ⇒ StartNginx
Returns a new instance of StartNginx.
9 10 11 12 13 14 |
# File 'lib/ruby/nginx/commands/start_nginx.rb', line 9 def initialize(sudo: false) @sudo = sudo sudo_reason = "Allow sudo elevation to start NGINX?" super(cmd: sudoify("nginx", sudo, sudo_reason), raise: Ruby::Nginx::StartError) end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ruby/nginx/commands/start_nginx.rb', line 16 def run super rescue Ruby::Nginx::StartError raise if @sudo # Elevate to sudo and try again. self.class.new(sudo: true).run end |