Grooming.

- Service#running?(pid_dir) added.
  - No attempt to stop services not running is being made by `stop`
    anymore.
master
Luka Vandervelden 2019-06-08 19:12:23 +02:00
parent e331828c8b
commit 9a93937176
1 changed files with 11 additions and 10 deletions

View File

@ -291,6 +291,9 @@ class Service
Status::Stopped Status::Stopped
end end
end end
def running?(pid_dir)
status(pid_dir) == Service::Status::Running
end
def to_s def to_s
"#{name} (in #{@environment.name})" "#{name} (in #{@environment.name})"
@ -445,9 +448,7 @@ begin
services.each do |service| services.each do |service|
service.dependency_tree.flatten.reverse.each do |service| service.dependency_tree.flatten.reverse.each do |service|
if service.status(PID_DIRECTORY) == Service::Status::Running next if service.running? PID_DIRECTORY
next
end
puts "starting #{service.to_s}" puts "starting #{service.to_s}"
service.start PID_DIRECTORY, LOG_DIRECTORY service.start PID_DIRECTORY, LOG_DIRECTORY
@ -466,16 +467,16 @@ begin
services.each do |service| services.each do |service|
# FIXME: Build revdep tree and stop services started as dependencies? # FIXME: Build revdep tree and stop services started as dependencies?
if service.status(PID_DIRECTORY) == Service::Status::Running next if ! service.running? PID_DIRECTORY
# FIXME: Should we remove duplicate services from the # FIXME: Should we remove duplicate services from the
# tree once flattened? # tree once flattened?
service.reverse_dependency_tree.flatten.reverse.each do |service| service.reverse_dependency_tree.flatten.reverse.each do |service|
next if ! service.running? PID_DIRECTORY
puts "stopping #{service.to_s}" puts "stopping #{service.to_s}"
service.stop PID_DIRECTORY service.stop PID_DIRECTORY
end end
end end
end
elsif args[0] == "status" elsif args[0] == "status"
puts Service.new(args[1], args[2]?).status PID_DIRECTORY puts Service.new(args[1], args[2]?).status PID_DIRECTORY
elsif args[0] == "show" elsif args[0] == "show"