diff --git a/src/service.cr b/src/service.cr index 4b4104d..ba87c6f 100644 --- a/src/service.cr +++ b/src/service.cr @@ -129,7 +129,8 @@ begin end end elsif args[0] == "status" - child = Process.run "#{OWN_LIBEXEC_DIR}/status", [args[1]], + args.shift + child = Process.run "#{OWN_LIBEXEC_DIR}/status", args, output: Process::Redirect::Inherit, error: Process::Redirect::Inherit return_value = (child.exit_status / 256).to_i diff --git a/src/status.cr b/src/status.cr index 01b0a21..210260e 100644 --- a/src/status.cr +++ b/src/status.cr @@ -10,10 +10,33 @@ Service.load RC_DIRECTORY LibC.setuid 0 LibC.setgid 0 -Service.get_by_id(ARGV[0]).try do |service| - puts service.status PID_DIRECTORY - exit 0 +services = ARGV +if services.size == 0 + services = Service.all +else + services = services.map do |id| + Service.get_by_id id + end end -exit 1 +if services.size == 1 + services[0]?.try do |service| + puts service.status PID_DIRECTORY + exit 0 + end + + exit 1 +else + service_not_found = false + + services.each do |service| + if service.nil? + service_not_found = true + else + puts "#{service.id}: #{service.status PID_DIRECTORY}" + end + end + + exit 1 if service_not_found +end