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

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

Defined Under Namespace

Classes: SystemdUnit

Instance Method Summary collapse

Methods inherited from TaskLibrary

#initialize

Constructor Details

This class inherits a constructor from Tomo::TaskLibrary

Instance Method Details

#check_activeObject



29
30
31
32
33
34
35
36
37
# File 'lib/tomo/plugin/puma/tasks.rb', line 29

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



39
40
41
# File 'lib/tomo/plugin/puma/tasks.rb', line 39

def log
  remote.attach "journalctl", "-q", raw("--user-unit=#{service.name.shellescape}"), *settings[:run_args]
end

#restartObject



24
25
26
27
# File 'lib/tomo/plugin/puma/tasks.rb', line 24

def restart
  remote.run "systemctl", "--user", "start", socket.name
  remote.run "systemctl", "--user", "restart", service.name
end

#setup_systemdObject

rubocop:disable Metrics/AbcSize



7
8
9
10
11
12
13
14
15
16
# File 'lib/tomo/plugin/puma/tasks.rb', line 7

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



43
44
45
# File 'lib/tomo/plugin/puma/tasks.rb', line 43

def tail_log
  remote.attach "journalctl -q --user-unit=#{service.name.shellescape} -f"
end