Created
February 17, 2009 06:58
Revisions
-
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,7 +44,7 @@ end p1 = fork { exec SERVER_COMMAND } Signal.trap(0) { Process.kill("INT", p1) } Signal.trap("INT") { $stderr.puts "Shutting down server_restarter"; exit } check_for_changes -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def check_for_changes end def emphasized(m) "\e[1;1m\e[41m \e[0m \e[1;1m\e[1m #{m} \e[0m" end p1 = fork { exec SERVER_COMMAND } -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,9 +43,8 @@ end p1 = fork { exec SERVER_COMMAND } Signal.trap(0) { Process.kill("INT", p1) } Signal.trap("INT") { puts "Shutting down server_restarter"; exit } check_for_changes @@ -56,7 +55,7 @@ loop do changes = check_for_changes unless changes.empty? $stderr.puts emphasized("Changes found...#{changes.inspect}") Process.kill("INT", p1) p1 = fork { exec SERVER_COMMAND } end end -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,9 @@ POLL_DIRECTORIES = %w(app config db lib) POLL_TIME = 0.9 # In Seconds SERVER_COMMAND = "script/server" # For passenger: # SERVER_COMMAND = "touch tmp/restart.txt" Dir.chdir(File.dirname(__FILE__)+"/..") @states = {} -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ # # To install, just copy it into the scripts directory and set it to be executable. # # Jonathan Penn (http://www.wavethenavel.com) POLL_DIRECTORIES = %w(app config db lib) POLL_TIME = 0.9 # In Seconds -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,16 @@ #!/usr/bin/env ruby # # usage: script/server_restarter # # Rails autoloading, while nice in theory, frequently doesn't work. Since Rails 2.3+ # is so fast when completely reloading the server, I wrote this script to listen to the # given directories, and kill/restart the server when any file is changed. # # It's quick, simple, and it reliably reloads your application when changes are made. # # To install, just copy it into the scripts directory and set it to be executable. # # Jonathan Penn (http://www.wavethenavel.com POLL_DIRECTORIES = %w(app config db lib) POLL_TIME = 0.9 # In Seconds -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,7 @@ POLL_DIRECTORIES = %w(app config db lib) POLL_TIME = 0.9 # In Seconds SERVER_COMMAND = "script/server" Dir.chdir(File.dirname(__FILE__)+"/..") @states = {} @@ -45,4 +44,4 @@ loop do Process.kill("KILL", p1) p1 = fork { exec SERVER_COMMAND } end end -
jonathanpenn revised this gist
Feb 17, 2009 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,10 @@ POLL_DIRECTORIES = %w(app config db lib) POLL_TIME = 0.9 # In Seconds SERVER_COMMAND = "script/server" ROOT_DIR = File.expand_path(File.dirname(__FILE__)+"/..").gsub(" ", "\ ") Dir.chdir(ROOT_DIR) @states = {} -
jonathanpenn renamed this gist
Feb 17, 2009 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,14 @@ #!/usr/bin/env ruby POLL_DIRECTORIES = %w(app config db lib) POLL_TIME = 0.9 # In Seconds SERVER_COMMAND = 'script/server' @states = {} def check_for_changes changes = [] Dir[*POLL_DIRECTORIES.map{|i|i+"/**/*"}].each do |file| unless File.symlink?(file) new_time = File.stat(file).mtime if @states[file] != new_time @@ -23,6 +20,10 @@ def check_for_changes changes end def emphasized(m) "\e[1;1m\e[41m \e[0m \e[1;1m\e[5m #{m} \e[0m" end p1 = fork { exec SERVER_COMMAND } Signal.trap(0) do @@ -31,15 +32,14 @@ end check_for_changes $stderr.puts "server_restarter running...watching #{@states.length} files every #{POLL_TIME} seconds." loop do sleep POLL_TIME changes = check_for_changes unless changes.empty? $stderr.puts emphasized("Changes found...#{changes.inspect}") Process.kill("KILL", p1) p1 = fork { exec SERVER_COMMAND } end end -
jonathanpenn created this gist
Feb 17, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #!/usr/bin/env ruby # SERVER_COMMAND = 'spin' SERVER_COMMAND = 'script/server' POLL_TIME = 1.1 # In Seconds @states = {} def check_for_changes changes = [] Dir.glob("./**/*").reject do |file| file =~ %r{^\./(log|public|doc)} end.each do |file| unless File.symlink?(file) new_time = File.stat(file).mtime if @states[file] != new_time @states[file] = new_time changes << file end end end changes end p1 = fork { exec SERVER_COMMAND } Signal.trap(0) do Process.kill("KILL", p1) end check_for_changes loop do sleep POLL_TIME changes = check_for_changes unless changes.empty? print "\n\n\nChanges found..." p changes puts "\n\n" Process.kill("KILL", p1) p1 = fork { exec SERVER_COMMAND } end end