Class: Tomo::Plugin::Puma::Tasks
- Inherits:
-
TaskLibrary
- Object
- TaskLibrary
- Tomo::Plugin::Puma::Tasks
- Defined in:
- lib/tomo/plugin/puma/tasks.rb
Defined Under Namespace
Classes: SystemdUnit
Class Method Summary collapse
-
.polling_delay ⇒ Object
Exposed to allow override during unit tests.
Instance Method Summary collapse
- #check_active ⇒ Object
- #log ⇒ Object
- #restart ⇒ Object
-
#setup_systemd ⇒ Object
rubocop:disable Metrics/AbcSize.
- #tail_log ⇒ Object
Methods inherited from TaskLibrary
Constructor Details
This class inherits a constructor from Tomo::TaskLibrary
Class Method Details
.polling_delay ⇒ Object
Exposed to allow override during unit tests
8 |
# File 'lib/tomo/plugin/puma/tasks.rb', line 8 def self.polling_delay = 1 |
Instance Method Details
#check_active ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/tomo/plugin/puma/tasks.rb', line 32 def check_active logger.info "Checking if puma is active and listening on port #{port}..." active = wait_until { dry_run? || (assert_active! && listening?) } remote.run("systemctl", "--user", "status", service.name) return if active logger.warn "Timed out waiting for puma to respond on port #{port}" end |
#log ⇒ Object
42 43 44 |
# File 'lib/tomo/plugin/puma/tasks.rb', line 42 def log remote.attach "journalctl", "-q", raw("--user-unit=#{service.name.shellescape}"), *settings[:run_args] end |
#restart ⇒ Object
27 28 29 30 |
# File 'lib/tomo/plugin/puma/tasks.rb', line 27 def restart remote.run "systemctl", "--user", "start", socket.name remote.run "systemctl", "--user", "restart", service.name end |
#setup_systemd ⇒ Object
rubocop:disable Metrics/AbcSize
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tomo/plugin/puma/tasks.rb', line 10 def setup_systemd # rubocop:disable Metrics/AbcSize linger_must_be_enabled! setup_directories remote.write template: socket.template, to: socket.path remote.write template: service.template, to: service.path remote.run "systemctl --user daemon-reload" remote.run "systemctl", "--user", "enable", service.name, socket.name end |
#tail_log ⇒ Object
46 47 48 |
# File 'lib/tomo/plugin/puma/tasks.rb', line 46 def tail_log remote.attach "journalctl -q --user-unit=#{service.name.shellescape} -f" end |