Sha256: 0ccfa9f272694e5c679c07f498a4e456c83f6fe1800b71618d8fd584492d2785

Contents?: true

Size: 1.07 KB

Versions: 30

Compression:

Stored size: 1.07 KB

Contents

module Nginxtra
  module Action
    @@ignore_force = false

    def initialize(thor, config)
      @thor = thor
      @config = config
    end

    # Run a daemon command to start or stop the nginx process.
    def daemon(action, additional_options = nil)
      action = "#{action} #{additional_options}" if additional_options
      run! "#{sudo}start-stop-daemon --#{action} --quiet --pidfile #{Nginxtra::Config.nginx_pidfile} --exec #{Nginxtra::Config.nginx_executable}"
    end

    private
    def run!(command)
      @thor.run command
      raise Nginxtra::Error::RunFailed.new("The last run command failed") unless $?.success?
    end

    def without_force
      @@ignore_force = true
      yield
    ensure
      @@ignore_force = false
    end

    def force?
      return false if @@ignore_force
      @thor.options["force"]
    end

    def interactive?
      !non_interactive?
    end

    def non_interactive?
      @thor.options["non-interactive"]
    end

    def sudo(force = false)
      "sudo " if (force || (@config && @config.require_root?)) && Process.uid != 0
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nginxtra-1.8.0.11 lib/nginxtra/action.rb
nginxtra-1.8.0.10 lib/nginxtra/action.rb
nginxtra-1.8.0.9 lib/nginxtra/action.rb
nginxtra-1.6.3.9 lib/nginxtra/action.rb
nginxtra-1.6.2.9 lib/nginxtra/action.rb
nginxtra-1.6.1.9 lib/nginxtra/action.rb
nginxtra-1.6.0.9 lib/nginxtra/action.rb
nginxtra-1.4.7.9 lib/nginxtra/action.rb
nginxtra-1.4.6.9 lib/nginxtra/action.rb
nginxtra-1.4.5.9 lib/nginxtra/action.rb
nginxtra-1.4.4.9 lib/nginxtra/action.rb
nginxtra-1.4.3.9 lib/nginxtra/action.rb
nginxtra-1.4.2.9 lib/nginxtra/action.rb
nginxtra-1.4.1.9 lib/nginxtra/action.rb
nginxtra-1.4.0.9 lib/nginxtra/action.rb
nginxtra-1.4.0.8 lib/nginxtra/action.rb
nginxtra-1.2.8.8 lib/nginxtra/action.rb
nginxtra-1.2.7.8 lib/nginxtra/action.rb
nginxtra-1.2.6.8 lib/nginxtra/action.rb
nginxtra-1.2.6.7 lib/nginxtra/action.rb