service add-environment <name>, bugfixes.
parent
c6dd306361
commit
de2b124d09
|
@ -165,6 +165,8 @@ begin
|
|||
Service.all.map do |service|
|
||||
puts service.to_s
|
||||
end
|
||||
elsif args[0] == "add-environment"
|
||||
Environment.new(args[1]).write ENVIRONMENTS_DIRECTORY
|
||||
elsif args[0] == "list-environments"
|
||||
Environment.all.map do |env|
|
||||
puts env.to_s
|
||||
|
|
|
@ -12,7 +12,12 @@ class Environment
|
|||
getter checks = Array(ServiceDefinition::Checks).new
|
||||
|
||||
def initialize()
|
||||
@name = "root"
|
||||
initialize "root"
|
||||
end
|
||||
|
||||
def initialize(@name, type = "prefix")
|
||||
@type = Type.parse type
|
||||
|
||||
@checks = Array(ServiceDefinition::Checks).new
|
||||
|
||||
# FIXME: Should this *really* be here?
|
||||
|
@ -59,6 +64,17 @@ class Environment
|
|||
end
|
||||
end
|
||||
|
||||
def write(dir : String)
|
||||
File.write "#{dir}/#{@name}.spec", to_spec
|
||||
end
|
||||
|
||||
def to_spec
|
||||
[
|
||||
"name: #{@name}",
|
||||
"type: #{@type.to_s}"
|
||||
].join("\n") + "\n"
|
||||
end
|
||||
|
||||
def self.get(name)
|
||||
_def = @@all.find &.name.==(name)
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ class Service
|
|||
end
|
||||
|
||||
def get_pid_file(pid_dir)
|
||||
"#{pid_dir}/#{name}.pid"
|
||||
"#{pid_dir}/#{name}.#{environment.name}.pid"
|
||||
end
|
||||
|
||||
def pid(pid_dir)
|
||||
|
@ -342,16 +342,10 @@ class Service
|
|||
unless matches # Should not happen, above regex would always match.
|
||||
raise Exception.new "FIXME"
|
||||
end
|
||||
environment_name = matches[0]
|
||||
service_name = if environment_name == id
|
||||
environment_name = "root"
|
||||
id
|
||||
else
|
||||
id.sub 0..matches[0].size, ""
|
||||
end
|
||||
environment_name, service_name = Service.parse_id id
|
||||
|
||||
@@all.find do |service|
|
||||
service.name == service_name
|
||||
service.name == service_name && service.environment.name == environment_name
|
||||
end
|
||||
end
|
||||
def is_id?(id)
|
||||
|
|
Loading…
Reference in New Issue