whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: restart passenger applications faster after change
Date Thu, 01 Feb 2018 12:46:13 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 51bfacf  restart passenger applications faster after change
51bfacf is described below

commit 51bfacfc86eb3c84e1c253687227d6218b5cf05d
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Thu Feb 1 07:10:30 2018 -0500

    restart passenger applications faster after change
    
    this may mean that some applications are restarted a second time after
    newer versions of gems are installed.
---
 Rakefile | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/Rakefile b/Rakefile
index badaf2b..04a4ca6 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,6 +8,23 @@ end
 
 # update gems and restart applications as needed
 task :update, [:command] do |task, args|
+  # determine last update time
+  update_file = "#{Process.uid == 0 ? '/root' : Dir.home}/.whimsy-update"
+  new_baseline = Time.now
+  old_baseline = File.mtime(update_file) rescue Time.at(0)
+
+  # restart passenger applications that have changed since the last update
+  Dir['**/config.ru'].each do |rackapp|
+    Dir.chdir File.dirname(rackapp) do
+      last_update = Dir['**/*'].map {|n| File.mtime n rescue Time.at(0)}.max
+      if last_update > old_baseline and Dir.exist? 'tmp'
+        FileUtils.touch 'tmp/.restart.txt'
+        FileUtils.chmod 0777, 'tmp/.restart.txt'
+        FileUtils.mv 'tmp/.restart.txt', 'tmp/restart.txt'
+      end
+    end
+  end
+
   # locate system ruby
   sysruby = File.realpath(`which ruby`.chomp)
   sysruby = "#{File.dirname(sysruby)}/%s#{sysruby[/ruby([.\d]*)$/, 1]}"
@@ -32,24 +49,19 @@ task :update, [:command] do |task, args|
         bundler = (File.exist?('config.ru') ? passruby : sysruby) % 'bundle'
       end
 
+      locktime = File.mtime('Gemfile.lock') rescue Time.at(0)
+
       bundler = 'bundle' unless File.exist?(bundler)
       system "#{bundler} #{args.command || 'update'}"
-    end
-  end
 
-  # determine last update time
-  update_file = "#{Process.uid == 0 ? '/root' : Dir.home}/.whimsy-update"
-  new_baseline = Time.now
-  old_baseline = File.mtime(update_file) rescue Time.at(0)
-
-  # restart passenger applications that have changed since the last update
-  Dir['**/config.ru'].each do |rackapp|
-    Dir.chdir File.dirname(rackapp) do
-      last_update = Dir['**/*'].map {|n| File.mtime n rescue Time.at(0)}.max
-      if last_update > old_baseline and Dir.exist? 'tmp'
-        FileUtils.touch 'tmp/.restart.txt'
-        FileUtils.chmod 0777, 'tmp/.restart.txt'
-        FileUtils.mv 'tmp/.restart.txt', 'tmp/restart.txt'
+      # if new gems were istalled and this directory contains a passenger
+      #  application, restart it
+      if (File.mtime('Gemfile.lock') rescue Time.at(0)) != locktime
+        if File.exist?('tmp/restart.txt')
+          FileUtils.touch 'tmp/.restart.txt'
+          FileUtils.chmod 0777, 'tmp/.restart.txt'
+          FileUtils.mv 'tmp/.restart.txt', 'tmp/restart.txt'
+        end
       end
     end
   end

-- 
To stop receiving notification emails like this one, please contact
rubys@apache.org.

Mime
View raw message