You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2018/02/01 12:46:13 UTC
[whimsy] branch master updated: restart passenger applications
faster after change
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 <ru...@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.
Re: [whimsy] branch master updated: restart passenger applications
faster after change
Posted by Sam Ruby <ru...@intertwingly.net>.
On Thu, Feb 1, 2018 at 7:46 AM, <ru...@apache.org> wrote:
>
> restart passenger applications faster after change
First test of this. Craig pushed a change.
The timestamp on the commit is Thu Feb 1 11:51:08 2018 -0800.
Commit message was sent at 01 Feb 2018 19:51:16 +0000. This likely
matches the time of the push.
The timestamp on restart.txt is 2018-02-01 19:51:18 +0000.
- Sam Ruby