Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/nginx/manifests/init.pp

Issue 29409691: Noissue - Void nginx $restart_command after package upgrade (Closed)
Patch Set: Created April 11, 2017, 3:51 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 class nginx ( 1 class nginx (
2 $worker_processes = $nginx::params::worker_processes, 2 $worker_processes = $nginx::params::worker_processes,
3 $worker_connections = $nginx::params::worker_connections, 3 $worker_connections = $nginx::params::worker_connections,
4 $ssl_session_cache = $nginx::params::ssl_session_cache, 4 $ssl_session_cache = $nginx::params::ssl_session_cache,
5 $geoip_country = undef, 5 $geoip_country = undef,
6 $geoip_city = undef, 6 $geoip_city = undef,
7 ) inherits nginx::params { 7 ) inherits nginx::params {
8 8
9 # Class['ssh'] is assumed to handle SSL-related quirks and therefore 9 # Class['ssh'] is assumed to handle SSL-related quirks and therefore
10 # the inclusion here became necessary. 10 # the inclusion here became necessary.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 $find_chmod_base = [$find_cmd_base, '-not', '-perm', '0640'] 213 $find_chmod_base = [$find_cmd_base, '-not', '-perm', '0640']
214 $find_chmod_exec = ['-ls', '-exec', 'chmod', '0640', '{}', ';'] 214 $find_chmod_exec = ['-ls', '-exec', 'chmod', '0640', '{}', ';']
215 215
216 exec {"set_logfiles_permissions": 216 exec {"set_logfiles_permissions":
217 command => shellquote($find_chmod_base, $find_chmod_exec), 217 command => shellquote($find_chmod_base, $find_chmod_exec),
218 unless => shellquote($find_chmod_base, $find_kill_exec), 218 unless => shellquote($find_chmod_base, $find_kill_exec),
219 subscribe => Service['nginx'], 219 subscribe => Service['nginx'],
220 } 220 }
221 221
222 $restart_command = join([ 222 $restart_command = join([
223 'rm /tmp/nginx-restart-lock 2>/dev/null || (',
223 'set -e', 224 'set -e',
224 'pid=`cat /var/run/nginx.pid`', 225 'pid=`cat /var/run/nginx.pid`',
225 'kill -USR2 "$pid"', 226 'kill -USR2 "$pid"',
226 'sleep 2', 227 'sleep 2',
227 'kill -QUIT "$pid"', 228 'kill -QUIT "$pid"',
229 ')',
228 ], "\n") 230 ], "\n")
229 231
230 service {'nginx': 232 service {'nginx':
231 ensure => running, 233 ensure => running,
232 enable => true, 234 enable => true,
233 restart => $restart_command, 235 restart => $restart_command,
234 hasstatus => true, 236 hasstatus => true,
235 require => Package['nginx'], 237 require => Package['nginx'],
236 } 238 }
237 239
238 Service['nginx'] <~ Class['ssh'] 240 Service['nginx'] <~ Class['ssh']
239 241
240 file {'/usr/share/nginx/html/50x.html': 242 file {'/usr/share/nginx/html/50x.html':
241 mode => 0644, 243 mode => 0644,
242 owner => 'root', 244 owner => 'root',
243 require => Package['nginx'], 245 require => Package['nginx'],
244 source => 'puppet:///modules/nginx/50x.html', 246 source => 'puppet:///modules/nginx/50x.html',
245 } 247 }
248
249 # This little hack is required to ensure the $restart_command being voided
250 # when the package is upgraded or installed for the first time, in which case
251 # the package maintainer's scripts would conflict with the Puppet resources,
252 # terminating both new and old processes (see http://hub.eyeo.com/issues/408)
253 exec {'nginx-update-hook':
254 before => Service['nginx'],
255 command => '/usr/bin/env touch /tmp/nginx-restart-lock',
256 refreshonly => true,
257 subscribe => Package['nginx'],
258 }
259
260 # The package does not know about the lock file, hence it is required to
261 # manually ensure the file being absent afterwards, for the next run
262 file {'/tmp/nginx-restart-lock':
263 ensure => 'absent',
264 require => Service['nginx'],
265 }
246 } 266 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld