Services can now be "Non Runnable".
This commit is contained in:
parent
10cd792373
commit
e0e81d8581
@ -1,4 +1,4 @@
|
||||
command: echo "coucou"
|
||||
command: none
|
||||
consumes: www
|
||||
requires-domain: true
|
||||
|
||||
|
@ -193,6 +193,11 @@ commands.push "start", "Starts a service." do
|
||||
service.dependency_tree.flatten.reverse.each do |service|
|
||||
next if service.running? PID_DIRECTORY
|
||||
|
||||
if service.non_runnable
|
||||
STDOUT << "#{service.to_s}: non runnable\n"
|
||||
next
|
||||
end
|
||||
|
||||
puts "starting #{service.to_s}"
|
||||
service.start PID_DIRECTORY, LOG_DIRECTORY
|
||||
end
|
||||
|
@ -176,6 +176,9 @@ class Service
|
||||
def port_definitions
|
||||
@reference.port_definitions
|
||||
end
|
||||
def non_runnable
|
||||
@reference.non_runnable
|
||||
end
|
||||
|
||||
def root
|
||||
@root || "#{@environment.root}/#{name}"
|
||||
@ -306,6 +309,11 @@ class Service
|
||||
# - Should we wait for the process to die?
|
||||
# - Shouldn’t we remove the pid file?
|
||||
def stop(pid_dir : String)
|
||||
if non_runnable
|
||||
STDOUT << ("%-20s " % "#{full_id}:").colorize(:white).to_s
|
||||
STDOUT << "non runnable"
|
||||
return
|
||||
end
|
||||
_pid = pid pid_dir
|
||||
|
||||
if _pid
|
||||
@ -344,9 +352,11 @@ class Service
|
||||
Running
|
||||
Dead
|
||||
Stopped
|
||||
NonRunnable
|
||||
end
|
||||
|
||||
def status(pid_dir)
|
||||
return Status::NonRunnable if non_runnable
|
||||
_pid = pid pid_dir
|
||||
|
||||
if _pid
|
||||
|
@ -62,6 +62,7 @@ class ServiceDefinition
|
||||
getter pre_start_hooks : Array(Hook)
|
||||
getter provides : Array(Provides)
|
||||
getter port_definitions : Array(PortDefinition)
|
||||
getter non_runnable : Bool
|
||||
|
||||
getter requires_domain = false
|
||||
|
||||
@ -69,6 +70,7 @@ class ServiceDefinition
|
||||
sections = specs.sections
|
||||
specs = specs.assignments
|
||||
@command = specs["command"].as_s
|
||||
@non_runnable = (@command == "none")
|
||||
@stop_command = specs["stop-command"]?.try &.as_s
|
||||
@directory = specs["directory"]?.try &.as_s
|
||||
@user = specs["user"]?.try &.as_s
|
||||
|
@ -40,12 +40,14 @@ else
|
||||
if verbose
|
||||
STDOUT << ("%-20s " % "#{service.full_id}:").colorize(:white).to_s
|
||||
|
||||
status_string = "%-10s" % service.status PID_DIRECTORY
|
||||
status_string = "%-15s" % service.status PID_DIRECTORY
|
||||
status_string = case service.status PID_DIRECTORY
|
||||
when Service::Status::Dead
|
||||
status_string.colorize(:red).bright
|
||||
when Service::Status::Running
|
||||
status_string.colorize(:green).bright
|
||||
when Service::Status::NonRunnable
|
||||
status_string.colorize(:cyan)
|
||||
when Service::Status::Stopped
|
||||
status_string.colorize :yellow
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user