Class: Bard::Provision::Nginx

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

Overview

install nginx

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)


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

def app_configured?
  provision_server.run "[ -f /etc/nginx/sites-enabled/#{config.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
# File 'lib/bard/new/provision/nginx.rb', line 4

def call
  print "Nginx:"
  if !http_responding?
    print " Installing nginx,"
    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 nginx",
      "sudo rm -f /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)


24
25
26
# File 'lib/bard/new/provision/nginx.rb', line 24

def http_responding?
  provision_server.run "nc -zv localhost 80 2>/dev/null", home: true, quiet: true
end