Class: Wheneverd::Systemd::Systemctl
- Inherits:
-
Object
- Object
- Wheneverd::Systemd::Systemctl
- Defined in:
- lib/wheneverd/systemd/systemctl.rb
Overview
Thin wrapper around systemctl that raises on non-zero exit status.
Class Method Summary collapse
-
.run(*args, user: true) ⇒ Array(String, String)
Run
systemctland return stdout/stderr.
Class Method Details
.run(*args, user: true) ⇒ Array(String, String)
Run systemctl and return stdout/stderr.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wheneverd/systemd/systemctl.rb', line 15 def self.run(*args, user: true) cmd = ["systemctl"] cmd << "--user" if user cmd << "--no-pager" cmd.concat(args.flatten.map(&:to_s)) stdout, stderr, status = Open3.capture3(*cmd) raise SystemctlError, format_error(cmd, status, stdout, stderr) unless status.success? [stdout, stderr] end |