| Index: modules/nginx/manifests/init.pp |
| diff --git a/modules/nginx/manifests/init.pp b/modules/nginx/manifests/init.pp |
| index e5596f8feb2f4cd7b785fa6abe3590b35ba99571..ee186ed7dea62754b4b27456aa8cad0154be9271 100644 |
| --- a/modules/nginx/manifests/init.pp |
| +++ b/modules/nginx/manifests/init.pp |
| @@ -220,11 +220,13 @@ class nginx ( |
| } |
| $restart_command = join([ |
| + 'rm /tmp/nginx-restart-lock 2>/dev/null || (', |
| 'set -e', |
| 'pid=`cat /var/run/nginx.pid`', |
| 'kill -USR2 "$pid"', |
| 'sleep 2', |
| 'kill -QUIT "$pid"', |
| + ')', |
| ], "\n") |
| service {'nginx': |
| @@ -243,4 +245,22 @@ class nginx ( |
| require => Package['nginx'], |
| source => 'puppet:///modules/nginx/50x.html', |
| } |
| + |
| + # This little hack is required to ensure the $restart_command being voided |
| + # when the package is upgraded or installed for the first time, in which case |
| + # the package maintainer's scripts would conflict with the Puppet resources, |
| + # terminating both new and old processes (see http://hub.eyeo.com/issues/408) |
| + exec {'nginx-update-hook': |
| + before => Service['nginx'], |
| + command => '/usr/bin/env touch /tmp/nginx-restart-lock', |
| + refreshonly => true, |
| + subscribe => Package['nginx'], |
| + } |
| + |
| + # The package does not know about the lock file, hence it is required to |
| + # manually ensure the file being absent afterwards, for the next run |
| + file {'/tmp/nginx-restart-lock': |
| + ensure => 'absent', |
| + require => Service['nginx'], |
| + } |
| } |