Pre-start checks/scripts can be defined.
parent
5aadf3c7ed
commit
0378d43224
29
src/main.cr
29
src/main.cr
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue