fixingthenet-installer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cef1f66f36fcf75fceeeaf5054e9f69b9340659e
4
- data.tar.gz: 8a689e079f82a96a669363394266c135559732bf
3
+ metadata.gz: a19a2e2a1a4a47765b754a9f01735f1a93ccc9a7
4
+ data.tar.gz: 860eb0c3111e9266bfd981b28f74214f1320521e
5
5
  SHA512:
6
- metadata.gz: d6ead90af49b3c5ed97ee0011e35f8316288099e2ec78e928cc909d46a40cfcc51fedd95cf48658a00cb1da8b56e74c64cf711c370f9559daae9029e7e8caa7b
7
- data.tar.gz: 7afb6c3b520dd4e1c9e089e244da9ff96d2e838cd5048f936a40ea903f9f4a7cb428aed282224a4de5c18cfa99f059468a266c6f33c294ec75e5ca2571dc4463
6
+ metadata.gz: 20213ed78a5e3107134aafc2bb11360d9e92b6c8448727f1301d3b096f803976e87a9e718289c84811fd72740fdc3dc05c0278c56863cc3e73de453459a45d48
7
+ data.tar.gz: c912d848a0cae390e9676d8fe42ca2261c32921d46ba241c4903db0a3293c74b5989bebdf208b20d73fb21b561a7e78a13f1f7e2286fbbad88a1d691b69e03ce
data/bin/ftn CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__),"..","lib")) if $PROGRAMM_NAME='bin/ftn'
3
4
 
4
5
  require 'fixingthenet/installer'
5
6
 
@@ -14,11 +14,14 @@ module Fixingthenet
14
14
  module Installer
15
15
 
16
16
  TEMPLATES_DIR=Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), '..', '..','templates')))
17
- NGINX_SITES_DIR=Pathname.new "/etc/nginx/sites-enabled/"
17
+ NGINX_APPS_DIR=Pathname.new "/etc/fixingthenet/nginx/apps"
18
+ NGINX_SITES_DIR=Pathname.new "/etc/nginx/sites-enabled"
19
+
18
20
  INITD_DIR=Pathname.new("/etc/init.d/")
19
21
 
20
22
  DEFAULT_OPTIONS = {:apps_root => Pathname.new('/vagrant/apps'),
21
23
  :template_path => TEMPLATES_DIR,
24
+ :nginx_apps_dir => NGINX_APPS_DIR,
22
25
  :env => 'development',
23
26
  :server_name => '192.168.40.10'
24
27
  }
@@ -11,6 +11,7 @@ module Fixingthenet
11
11
  def root
12
12
  apps_root.join(full_name)
13
13
  end
14
+
14
15
  end
15
16
 
16
17
  end
@@ -3,15 +3,16 @@ module Fixingthenet
3
3
  class Command
4
4
  attr_reader :args
5
5
  attr_reader :options
6
+ attr_reader :app
6
7
 
7
8
  def initialize(_options, args=[])
8
9
  @options=_options
9
10
  @args=args
10
11
  parse_options unless args.empty?
11
12
 
12
- app=App.new(options)
13
+ @app=App.new(options)
13
14
  puts "options: #{options}" if options[:verbose]
14
- command(app)
15
+ command
15
16
  end
16
17
 
17
18
  private
@@ -27,19 +27,26 @@ module Fixingthenet
27
27
  end.parse!(args)
28
28
  end
29
29
 
30
- def command(app)
31
- {app.template_path.join('nginx_app.conf.erb') => NGINX_SITES_DIR.join(app.full_name),
30
+ def command
31
+ # make sure the site exists
32
+ render(app.template_path.join('nginx_app.conf.erb'),NGINX_SITES_DIR.join("fixingthenet-#{app.server_name}"))
33
+
34
+ # install the location handler
35
+ {app.template_path.join('app.conf.erb') => NGINX_APPS_DIR.join(app.full_name),
32
36
  app.template_path.join('initd.conf.erb') => INITD_DIR.join(app.full_name)
33
37
  }.each do |template_name, destination|
34
- template=File.read(template_name)
35
- content=ERB.new(template).result(binding)
36
- puts "#{template_name} -> #{destination}" if options[:verbose]
37
- write_content(destination, content)
38
+ render(template_name, destination)
38
39
  end
39
40
 
40
41
  `sudo /etc/init.d/#{app.full_name} reload`
41
42
  end
42
43
 
44
+ def render(template_name, destination)
45
+ content=ERB.new(File.read(template_name)).result(binding)
46
+ puts "#{template_name} -> #{destination}" if options[:verbose]
47
+ write_content(destination, content)
48
+ end
49
+
43
50
  def write_content(file, content)
44
51
  File.open(file, "w") do |fd|
45
52
  fd.write content
@@ -14,11 +14,11 @@ module Fixingthenet
14
14
  end.parse!(args)
15
15
  end
16
16
 
17
- def command(app)
17
+ def command
18
18
  initd_filename="/etc/init.d/#{app.full_name}"
19
19
  `sudo #{initd_filename} stop` if File.exist?(initd_filename)
20
20
  [
21
- NGINX_SITES_DIR.join(app.full_name),
21
+ NGINX_APPS_DIR.join(app.full_name),
22
22
  INITD_DIR.join(app.full_name)
23
23
 
24
24
  ].each do |destination|
@@ -1,5 +1,5 @@
1
1
  module Fixingthenet
2
2
  module Installer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1,6 @@
1
+ location <%= app.mount_path %> {
2
+ proxy_pass http://localhost:<%= app.port %>;
3
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
4
+ proxy_set_header Host $http_host;
5
+ proxy_redirect off;
6
+ }
@@ -1,23 +1,3 @@
1
- #map $http_upgrade $connection_upgrade {
2
- # default upgrade;
3
- # '' close;
4
- #}
5
-
6
- #upstream websocket {
7
- # server localhost:<%= app.port %>;
8
- #}
9
-
10
- #server {
11
- # listen 8020;
12
- # location / {
13
- # proxy_pass http://websocket;
14
- # proxy_http_version 1.1;
15
- # proxy_set_header Upgrade $http_upgrade;
16
- # proxy_set_header Connection $connection_upgrade;
17
- # }
18
- #}
19
-
20
-
21
1
  server {
22
2
  #listen *:80 default_server;
23
3
  #server_name _;
@@ -30,26 +10,5 @@ server {
30
10
  error_log /var/log/nginx/error.log;
31
11
 
32
12
 
33
- location <%= app.mount_path %> {
34
- proxy_pass http://localhost:<%= app.port %>;
35
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
36
- proxy_set_header Host $http_host;
37
- proxy_redirect off;
38
- }
39
-
40
-
41
- # location ~ ^<%= app.root_path %>(assets|system)/ {
42
- # root <%= app.root %>/public;
43
- # expires 1y;
44
- # add_header Cache-Control public;
45
- # gzip_static on;
46
- # add_header ETag "";
47
- # break;
48
- # }
49
-
50
-
51
- # location ~ ^/(robots\.txt|favicon\.ico|.*\.html).*$ {
52
- # root <%= app.root %>/public;
53
- # }
54
-
13
+ include <%= app.nginx_apps_dir %>/*;
55
14
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixingthenet-installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Schrammel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ files:
60
60
  - lib/fixingthenet/installer/install_command.rb
61
61
  - lib/fixingthenet/installer/uninstall_command.rb
62
62
  - lib/fixingthenet/installer/version.rb
63
+ - templates/app.conf.erb
63
64
  - templates/initd.conf.erb
64
65
  - templates/nginx_app.conf.erb
65
66
  homepage: https://github.com/fixingthenet/fixingthenet-installer