Class: Do::Executor
- Inherits:
-
Object
- Object
- Do::Executor
- Defined in:
- lib/do/executor.rb
Overview
Executes a task's command as an argument list, without a shell.
The command string is split into argv tokens lexically (respecting
quoting but performing no variable expansion, ~ expansion, or globbing).
This is the safe, declarative default described in the spec. Tasks that
genuinely need shell features must request them explicitly, e.g. by
prefixing with bash -lc '...'.
Instance Attribute Summary collapse
-
#systemd ⇒ Object
readonly
Returns the value of attribute systemd.
Instance Method Summary collapse
-
#initialize(systemd: Systemd.new) ⇒ Executor
constructor
A new instance of Executor.
-
#run(task) ⇒ Integer
Run the task immediately and return its exit status.
Constructor Details
Instance Attribute Details
#systemd ⇒ Object (readonly)
Returns the value of attribute systemd.
13 14 15 |
# File 'lib/do/executor.rb', line 13 def systemd @systemd end |
Instance Method Details
#run(task) ⇒ Integer
Run the task immediately and return its exit status. The timer schedule is never altered by manual execution.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/do/executor.rb', line 23 def run(task) argv = Shellwords.split(task.command) raise Error, "task '#{task.name}' has an empty command" if argv.empty? env_overrides = task.environment || {} = {} [:chdir] = File.(task.working_directory) if task.working_directory pid = Process.spawn(env_overrides, *argv, ) _pid, status = Process.wait2(pid) status.exitstatus || 0 end |