Grooming.
- Service#running?(pid_dir) added. - No attempt to stop services not running is being made by `stop` anymore.master
parent
e331828c8b
commit
9a93937176
11
src/main.cr
11
src/main.cr
|
@ -291,6 +291,9 @@ class Service
|
|||
Status::Stopped
|
||||
end
|
||||
end
|
||||
def running?(pid_dir)
|
||||
status(pid_dir) == Service::Status::Running
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{name} (in #{@environment.name})"
|
||||
|
@ -445,9 +448,7 @@ begin
|
|||
|
||||
services.each do |service|
|
||||
service.dependency_tree.flatten.reverse.each do |service|
|
||||
if service.status(PID_DIRECTORY) == Service::Status::Running
|
||||
next
|
||||
end
|
||||
next if service.running? PID_DIRECTORY
|
||||
|
||||
puts "starting #{service.to_s}"
|
||||
service.start PID_DIRECTORY, LOG_DIRECTORY
|
||||
|
@ -466,16 +467,16 @@ begin
|
|||
|
||||
services.each do |service|
|
||||
# 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
|
||||
# tree once flattened?
|
||||
service.reverse_dependency_tree.flatten.reverse.each do |service|
|
||||
next if ! service.running? PID_DIRECTORY
|
||||
|
||||
puts "stopping #{service.to_s}"
|
||||
service.stop PID_DIRECTORY
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif args[0] == "status"
|
||||
puts Service.new(args[1], args[2]?).status PID_DIRECTORY
|
||||
elsif args[0] == "show"
|
||||
|
|
Loading…
Reference in New Issue