Grooming.
- Service#running?(pid_dir) added. - No attempt to stop services not running is being made by `stop` anymore.master
parent
e331828c8b
commit
9a93937176
21
src/main.cr
21
src/main.cr
|
@ -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,14 +467,14 @@ 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"
|
||||||
|
|
Loading…
Reference in New Issue