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 +4 -4
- data/bin/ftn +1 -0
- data/lib/fixingthenet/installer.rb +4 -1
- data/lib/fixingthenet/installer/app.rb +1 -0
- data/lib/fixingthenet/installer/command.rb +3 -2
- data/lib/fixingthenet/installer/install_command.rb +13 -6
- data/lib/fixingthenet/installer/uninstall_command.rb +2 -2
- data/lib/fixingthenet/installer/version.rb +1 -1
- data/templates/app.conf.erb +6 -0
- data/templates/nginx_app.conf.erb +1 -42
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a19a2e2a1a4a47765b754a9f01735f1a93ccc9a7
|
4
|
+
data.tar.gz: 860eb0c3111e9266bfd981b28f74214f1320521e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20213ed78a5e3107134aafc2bb11360d9e92b6c8448727f1301d3b096f803976e87a9e718289c84811fd72740fdc3dc05c0278c56863cc3e73de453459a45d48
|
7
|
+
data.tar.gz: c912d848a0cae390e9676d8fe42ca2261c32921d46ba241c4903db0a3293c74b5989bebdf208b20d73fb21b561a7e78a13f1f7e2286fbbad88a1d691b69e03ce
|
data/bin/ftn
CHANGED
@@ -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
|
-
|
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
|
}
|
@@ -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
|
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
|
31
|
-
|
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
|
-
|
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
|
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
|
-
|
21
|
+
NGINX_APPS_DIR.join(app.full_name),
|
22
22
|
INITD_DIR.join(app.full_name)
|
23
23
|
|
24
24
|
].each do |destination|
|
@@ -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
|
-
|
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.
|
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-
|
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
|