sapoku 0.0.9 → 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sapoku.rb +35 -3
- metadata +1 -1
data/lib/sapoku.rb
CHANGED
@@ -52,10 +52,14 @@ class Tadpole
|
|
52
52
|
# returns the actual raw console output of the generated commands
|
53
53
|
def bootstrap
|
54
54
|
self.save
|
55
|
-
output =
|
56
|
-
|
55
|
+
output = "Creating new container for your app using the #{@stack} stack"
|
56
|
+
output += `sudo lxc-clone -o #{@stack} -n #{@app_name}`
|
57
|
+
create_lxc_config
|
58
|
+
output += "Booting your new container"
|
57
59
|
output += `sudo lxc-start -n #{@app_name} -d`
|
58
60
|
create_iptables
|
61
|
+
output += "Creating nginx configuration file"
|
62
|
+
create_nginx_config
|
59
63
|
return output
|
60
64
|
end
|
61
65
|
|
@@ -72,9 +76,37 @@ class Tadpole
|
|
72
76
|
def get_binding
|
73
77
|
binding
|
74
78
|
end
|
79
|
+
|
80
|
+
def create_nginx_config
|
81
|
+
@ip = self.container_ip
|
82
|
+
@ram = self.ram
|
83
|
+
@name = self.app_name
|
84
|
+
|
85
|
+
template = %{
|
86
|
+
server {
|
87
|
+
listen 80;
|
88
|
+
server_name #{@name}.sapoku.webreakstuff.com;
|
89
|
+
access_log off;
|
90
|
+
error_log off;
|
91
|
+
|
92
|
+
location / {
|
93
|
+
proxy_pass http://#{@ip}:8080;
|
94
|
+
proxy_set_header X-Real-IP $remote_addr;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
erb = ERB.new(template)
|
100
|
+
|
101
|
+
File.open("#{@name}_nginx_config", 'w') do |f|
|
102
|
+
f.write erb.result(self.get_binding)
|
103
|
+
end
|
104
|
+
|
105
|
+
system("sudo mv #{@name}_nginx_config /opt/nginx/conf/containers/#{@name}.conf")
|
106
|
+
end
|
75
107
|
|
76
108
|
# generate a new config file
|
77
|
-
def
|
109
|
+
def create_lxc_config
|
78
110
|
@ip = self.container_ip
|
79
111
|
@ram = self.ram
|
80
112
|
@name = self.app_name
|