Class: Bard::Provision::Passenger

Inherits:
Bard::Provision show all
Defined in:
lib/bard/provision/passenger.rb

Overview

install nginx & passenger

Instance Attribute Summary

Attributes inherited from Bard::Provision

#config, #ssh_url

Instance Method Summary collapse

Methods inherited from Bard::Provision

call

Instance Method Details

#app_configured?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/bard/provision/passenger.rb', line 32

def app_configured?
  provision_server.run "[ -f /etc/nginx/sites-enabled/#{server.project_name} ]", quiet: true
end

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bard/provision/passenger.rb', line 4

def call
  print "Passenger:"
  if !http_responding?
    print " Installing nginx & Passenger,"
    provision_server.run! [
      %(grep -qxF "RAILS_ENV=production" /etc/environment || echo "RAILS_ENV=production" | sudo tee -a /etc/environment),
      %(grep -qxF "EDITOR=vim" /etc/environment || echo "EDITOR=vim" | sudo tee -a /etc/environment),
      "sudo apt-get install -y vim dirmngr gnupg apt-transport-https ca-certificates",
      "curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null",
      %(echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger jammy main" | sudo tee /etc/apt/sources.list.d/passenger.list),
      "sudo apt-get update -y",
      "sudo apt-get install -y nginx libnginx-mod-http-passenger",
      "sudo rm /etc/nginx/sites-enabled/default",
    ].join("; "), home: true
  end

  if !app_configured?
    print " Creating nginx config for app,"
    provision_server.run! "bard setup"
  end

  puts ""
end

#http_responding?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/bard/provision/passenger.rb', line 28

def http_responding?
  system "nc -zv #{provision_server.ssh_uri.host} 80 2>/dev/null"
end