-
Notifications
You must be signed in to change notification settings - Fork 1
Abort
An abort is an unwanted or unexpected termination of commands suspended by several reasons.
In Crystal Run, all the running processes are separated and asynchronous. So, even if some command is aborted, others will be continued.
If you want to stop commands running when some command fails, set the abort_on_error
attribute into contexts.
cg = Run::CommandGroup.new do |g|
g.command "wget", %w(http://essential.com), abort_on_error: true
g.command "wget", %w(http://optional.com)
end
cg.run
In this example, if wget http://essentail.com
exits with an error, the following command will never run.
In parallel processing, some processes may have been already started before other commands fail. In that case, exit signals are sent to the existing processes.
cg = Run::CommandGroup.new do |g|
g.command "wget", %w(http://essential.com), abort_on_error: true
g.command "wget", %w(http://optional.com)
end
cg.run parallel: true
In this example, if wget http://essential.com
exits with an error. an exit signal is sent to the process of wget http://optional.com
, only if the process is left.
The default signal number on abort is Signal::TERM. You can specify the number with the abort_signal
attribute.
cg = Run::CommandGroup.new do |g|
g.command "wget", %w(http://essential.com), abort_on_error: true
g.command "wget", %w(http://optional.com), abort_signal: Signal::INT
end