Pre-start checks/scripts can be defined.

master
Luka Vandervelden 2019-06-09 02:22:58 +02:00
parent 5aadf3c7ed
commit 0378d43224
1 changed files with 29 additions and 0 deletions

View File

@ -36,6 +36,13 @@ class ServiceDefinition
token: String token: String
}) })
end end
struct Checks
YAML.mapping({
name: String,
file: String, # FIXME: -> String? and add directory:?
command: String
})
end
YAML.mapping({ YAML.mapping({
name: String, name: String,
command: String, command: String,
@ -55,6 +62,10 @@ class ServiceDefinition
consumes: { consumes: {
type: Array(Consumes), type: Array(Consumes),
default: [] of Consumes default: [] of Consumes
},
checks: {
type: Array(Checks),
default: [] of Checks
} }
}) })
@ -222,6 +233,24 @@ class Service
end end
def start(pid_dir : String, log_dir : String) def start(pid_dir : String, log_dir : String)
@reference.checks.each do |check|
run_check = false
# Other tests will likely come later.
if check.file && ! File.exists? check.file
run_check = true
end
unless run_check
next
end
puts " - #{check.name}"
# FIXME: Output? Only in debug mode?
Process.run "sh", ["-c", check.command], output: Process::Redirect::Inherit, error: Process::Redirect::Inherit
end
command, args = split_command command command, args = split_command command
process = Process.fork do process = Process.fork do