# File lib/specinfra/processor.rb, line 3 def self.check_service_is_running(service) cmd = Specinfra.command.get(:check_service_is_running, service) ret = Specinfra.backend.run_command(cmd) # In Ubuntu, some services are under upstart and "service foo status" returns # exit status 0 even though they are stopped. # So return false if stdout contains "stopped/waiting" or "stop/waiting". return false if ret.stdout =~ /stop(ped)?\/waiting/ # If the service is not registered, check by ps command if ret.exit_status == 1 cmd = Specinfra.command.get(:check_process_is_running, service) ret = Specinfra.backend.run_command(cmd) end ret.success? end