diff --git a/src/main.cr b/src/main.cr index 6668dd0..1a638b0 100644 --- a/src/main.cr +++ b/src/main.cr @@ -36,6 +36,13 @@ class ServiceDefinition token: String }) end + struct Checks + YAML.mapping({ + name: String, + file: String, # FIXME: -> String? and add directory:? + command: String + }) + end YAML.mapping({ name: String, command: String, @@ -55,6 +62,10 @@ class ServiceDefinition consumes: { type: Array(Consumes), default: [] of Consumes + }, + checks: { + type: Array(Checks), + default: [] of Checks } }) @@ -222,6 +233,24 @@ class Service end 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 process = Process.fork do