Class: Tomo::Plugin::Puma::Tasks

Inherits:
TaskLibrary show all
Defined in:
lib/tomo/plugin/puma/tasks.rb

Defined Under Namespace

Classes: SystemdUnit

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TaskLibrary

#initialize

Constructor Details

This class inherits a constructor from Tomo::TaskLibrary

Class Method Details

.polling_delayObject

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_activeObject



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

#logObject



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

#restartObject



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_systemdObject

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_logObject



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