nginxinator 0.0.0 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nginxinator/nginx.rb +21 -18
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b829943382a3708dfe4e28c665d8fe93d65168cd
4
- data.tar.gz: c055ef06028e3bf7bcdca0ccd2c77d7745816ef4
3
+ metadata.gz: 97e381300f4c6982055907b1bd6bedee2e73dbe9
4
+ data.tar.gz: ac83622bc07d0e85ea78e1c6f8b8267d4b430089
5
5
  SHA512:
6
- metadata.gz: 1ce2ff7f57db5da8c751ed6756ac3cab26598b5285763793e86d6d25139e73abb1bb637a6ee15e744a0a8d342fa16ae370b32d5ebaf3bd1d2303c5612773e3b9
7
- data.tar.gz: 15184a3635cb2ffaf163002b9da4567ea6957f6e14fb139c77195c2f0f7fb12cfa4eb7bea967db1d266f2e011c2b9fa8a623906df4311add5df002f63ce4bd4f
6
+ metadata.gz: e17ec2d8c71c97915ff6158ed17457f452734d769f4303c9f7ba3a83d807334cc03e3b27f66b29fb8623575e299ecc849c4ebe1c945aeef382026b8b49f579c1
7
+ data.tar.gz: 133690c6a1e35f0e84e45ca4b695726ad191941617002c5de93dd7507b02e4df6a7ae02a6ce481e5c11dea4c5162913ce024024e8a6df9152c543954e6c4f2b4
@@ -22,7 +22,7 @@ namespace :nginx do
22
22
  on "#{settings.ssh_user}@#{settings.domain}" do
23
23
  config_file_changed = false
24
24
  settings.config_files.each do |config_file|
25
- if config_file_differs?(settings, settings.local_templates_path, settings.external_conf_path, config_file)
25
+ if nginx_config_file_differs?(settings, settings.local_templates_path, settings.external_conf_path, config_file)
26
26
  warn "Config file #{config_file} on #{settings.domain} is being updated."
27
27
  Rake::Task['nginx:install_config_file'].invoke(settings.local_templates_path, settings.external_conf_path, config_file)
28
28
  Rake::Task['nginx:install_config_file'].reenable
@@ -30,17 +30,17 @@ namespace :nginx do
30
30
  end
31
31
  end
32
32
  settings.sites_enabled.each do |config_file|
33
- if config_file_differs?(settings, settings.local_site_templates_path, settings.external_sites_enabled_path, config_file)
33
+ if nginx_config_file_differs?(settings, settings.local_site_templates_path, settings.external_sites_enabled_path, config_file)
34
34
  warn "Config file #{config_file} on #{settings.domain} is being updated."
35
35
  Rake::Task['nginx:install_config_file'].invoke(settings.local_site_templates_path, settings.external_sites_enabled_path, config_file)
36
36
  Rake::Task['nginx:install_config_file'].reenable
37
37
  config_file_changed = true
38
38
  end
39
39
  end
40
- unless container_exists?(settings.container_name)
40
+ unless nginx_container_exists?(settings.container_name)
41
41
  Rake::Task['nginx:create_container'].invoke
42
42
  else
43
- unless container_is_running?(settings.container_name)
43
+ unless nginx_container_is_running?(settings.container_name)
44
44
  Rake::Task['nginx:start_container'].invoke
45
45
  else
46
46
  if config_file_changed
@@ -58,10 +58,10 @@ namespace :nginx do
58
58
  settings = @settings
59
59
  on "#{settings.ssh_user}@#{settings.domain}" do
60
60
  info ""
61
- if container_exists?(settings.container_name)
61
+ if nginx_container_exists?(settings.container_name)
62
62
  info "#{settings.container_name} exists on #{settings.domain}"
63
63
  info ""
64
- if container_is_running?(settings.container_name)
64
+ if nginx_container_is_running?(settings.container_name)
65
65
  info "#{settings.container_name} is running on #{settings.domain}"
66
66
  info ""
67
67
  else
@@ -81,7 +81,7 @@ namespace :nginx do
81
81
  warn "Starting a new container named #{settings.container_name} on #{settings.domain}"
82
82
  execute("docker", "run", settings.docker_run_command)
83
83
  sleep 2
84
- fatal stay_running_message(settings) and raise unless container_is_running?(settings.container_name)
84
+ fatal nginx_stay_running_message(settings) and raise unless nginx_container_is_running?(settings.container_name)
85
85
  end
86
86
  end
87
87
 
@@ -91,7 +91,7 @@ namespace :nginx do
91
91
  warn "Starting an existing but non-running container named #{settings.container_name}"
92
92
  execute("docker", "start", settings.container_name)
93
93
  sleep 2
94
- fatal stay_running_message(settings) and raise unless container_is_running?(settings.container_name)
94
+ fatal nginx_stay_running_message(settings) and raise unless nginx_container_is_running?(settings.container_name)
95
95
  end
96
96
  end
97
97
 
@@ -101,7 +101,7 @@ namespace :nginx do
101
101
  warn "Restarting a running container named #{settings.container_name}"
102
102
  execute("docker", "restart", settings.container_name)
103
103
  sleep 2
104
- fatal stay_running_message(settings) and raise unless container_is_running?(settings.container_name)
104
+ fatal nginx_stay_running_message(settings) and raise unless nginx_container_is_running?(settings.container_name)
105
105
  end
106
106
  end
107
107
 
@@ -122,7 +122,7 @@ namespace :nginx do
122
122
  on "#{settings.ssh_user}@#{settings.domain}" do
123
123
  as 'root' do
124
124
  execute("mkdir", "-p", args.config_path) unless test("test", "-d", args.config_path)
125
- generated_config_file = generate_config_file(settings, "#{args.template_path}/#{args.config_file}.erb")
125
+ generated_config_file = nginx_generate_config_file(settings, "#{args.template_path}/#{args.config_file}.erb")
126
126
  upload! StringIO.new(generated_config_file), "/tmp/#{args.config_file}"
127
127
  execute("mv", "/tmp/#{args.config_file}", "#{args.config_path}/#{args.config_file}")
128
128
  execute("chown", "-R", "root:root", args.config_path)
@@ -146,15 +146,18 @@ namespace :nginx do
146
146
 
147
147
  private
148
148
 
149
- def stay_running_message(settings)
149
+ # Temporarily added 'nginx_' to the beginning of each of these methods to avoid
150
+ # getting them overwritten by other gems with methods with the same names, (E.G. postgresinator.)
151
+ ## TODO Figure out how to do this the right or better way.
152
+ def nginx_stay_running_message(settings)
150
153
  "Container #{settings.container_name} on #{settings.domain} did not stay running more than 2 seconds"
151
154
  end
152
155
 
153
- def config_file_differs?(settings, local_templates_path, external_config_path, config_file)
154
- generated_config_file = generate_config_file(settings, "#{local_templates_path}/#{config_file}.erb")
156
+ def nginx_config_file_differs?(settings, local_templates_path, external_config_path, config_file)
157
+ generated_config_file = nginx_generate_config_file(settings, "#{local_templates_path}/#{config_file}.erb")
155
158
  as 'root' do
156
159
  config_file_path = "#{external_config_path}/#{config_file}"
157
- if file_exists?(config_file_path)
160
+ if nginx_file_exists?(config_file_path)
158
161
  capture("cat", config_file_path).chomp != generated_config_file.chomp
159
162
  else
160
163
  true
@@ -162,23 +165,23 @@ namespace :nginx do
162
165
  end
163
166
  end
164
167
 
165
- def generate_config_file(settings, template_file_path)
168
+ def nginx_generate_config_file(settings, template_file_path)
166
169
  @settings = settings # needed for ERB
167
170
  template_path = File.expand_path(template_file_path)
168
171
  ERB.new(File.new(template_path).read).result(binding)
169
172
  end
170
173
 
171
- def container_exists?(container_name)
174
+ def nginx_container_exists?(container_name)
172
175
  test "docker", "inspect", container_name, ">", "/dev/null"
173
176
  end
174
177
 
175
- def container_is_running?(container_name)
178
+ def nginx_container_is_running?(container_name)
176
179
  (capture "docker", "inspect",
177
180
  "--format='{{.State.Running}}'",
178
181
  container_name).strip == "true"
179
182
  end
180
183
 
181
- def file_exists?(file_name_path)
184
+ def nginx_file_exists?(file_name_path)
182
185
  test "[", "-f", file_name_path, "]"
183
186
  end
184
187
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nginxinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - david amick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-16 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake