Grooming related to side-effects directories.
parent
f858a9aa11
commit
3e8a1d2ab2
25
src/main.cr
25
src/main.cr
|
@ -1,6 +1,13 @@
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
require "yaml"
|
require "yaml"
|
||||||
|
|
||||||
|
# Those are set to local to make testing easier.
|
||||||
|
PID_DIRECTORY = "./pid"
|
||||||
|
RC_DIRECTORY = "./rc"
|
||||||
|
LOG_DIRECTORY = "./log"
|
||||||
|
SERVICES_DIRECTORY = "./services"
|
||||||
|
ENVIRONMENTS_DIRECTORY = "./environments"
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# - Be more declarative about the definition of commands.
|
# - Be more declarative about the definition of commands.
|
||||||
|
|
||||||
|
@ -386,33 +393,33 @@ if command.nil?
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
ServiceDefinition.load "services"
|
ServiceDefinition.load SERVICES_DIRECTORY
|
||||||
Environment.load "environments"
|
Environment.load ENVIRONMENTS_DIRECTORY
|
||||||
Service.load "rc"
|
Service.load RC_DIRECTORY
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if args[0] == "help"
|
if args[0] == "help"
|
||||||
puts parser
|
puts parser
|
||||||
elsif args[0] == "add"
|
elsif args[0] == "add"
|
||||||
Service.new(args[1], args[2]?).write "rc"
|
Service.new(args[1], args[2]?).write RC_DIRECTORY
|
||||||
elsif args[0] == "del"
|
elsif args[0] == "del"
|
||||||
Service.new(args[1], args[2]?).remove "rc"
|
Service.new(args[1], args[2]?).remove RC_DIRECTORY
|
||||||
elsif args[0] == "start"
|
elsif args[0] == "start"
|
||||||
#service = Service.new(args[1], args[2]?)
|
#service = Service.new(args[1], args[2]?)
|
||||||
service = Service.get_by_id(args[1]).not_nil!
|
service = Service.get_by_id(args[1]).not_nil!
|
||||||
service.dependency_tree.flatten.reverse.each do |service|
|
service.dependency_tree.flatten.reverse.each do |service|
|
||||||
if service.status("pid") == Service::Status::Running
|
if service.status(PID_DIRECTORY) == Service::Status::Running
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "starting #{service.to_s}"
|
puts "starting #{service.to_s}"
|
||||||
service.start "pid", "log"
|
service.start PID_DIRECTORY, LOG_DIRECTORY
|
||||||
end
|
end
|
||||||
elsif args[0] == "stop"
|
elsif args[0] == "stop"
|
||||||
# FIXME: Build revdep tree and stop services started as dependencies?
|
# FIXME: Build revdep tree and stop services started as dependencies?
|
||||||
Service.new(args[1], args[2]?).stop "pid"
|
Service.new(args[1], args[2]?).stop PID_DIRECTORY
|
||||||
elsif args[0] == "status"
|
elsif args[0] == "status"
|
||||||
puts Service.new(args[1], args[2]?).status "pid"
|
puts Service.new(args[1], args[2]?).status PID_DIRECTORY
|
||||||
elsif args[0] == "show"
|
elsif args[0] == "show"
|
||||||
service = Service.all.find do |service|
|
service = Service.all.find do |service|
|
||||||
unless service.name == args[1]
|
unless service.name == args[1]
|
||||||
|
|
Loading…
Reference in New Issue