sapoku 0.0.9 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sapoku.rb +35 -3
  2. metadata +1 -1
@@ -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 = `sudo lxc-clone -o #{@stack} -n #{@app_name}`
56
- create_config
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 create_config
109
+ def create_lxc_config
78
110
  @ip = self.container_ip
79
111
  @ram = self.ram
80
112
  @name = self.app_name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapoku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: