tag:blogger.com,1999:blog-5732889.post1297653060529573248..comments2024-03-20T02:16:52.488-05:00Comments on Blog: Rails - Automatic Reloading and ModelsUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5732889.post-78785717168386318212008-02-20T16:30:00.000-06:002008-02-20T16:30:00.000-06:00I'm a Windows person, so the kill -9 won't work fo...I'm a Windows person, so the <I>kill -9</I> won't work for me. Either way, this is a cool script. Thanks, JasonJasonhttps://www.blogger.com/profile/10859950171794898662noreply@blogger.comtag:blogger.com,1999:blog-5732889.post-51437943699919270432008-02-14T15:30:00.000-06:002008-02-14T15:30:00.000-06:00I usually do something likewatcher_thread = Thread...I usually do something like<BR/>watcher_thread = Thread.new{<BR/>print 'starting watcher'<BR/>latest_inserted = Time.now<BR/>dirs = ['app/controllers', 'app/schools', '/app/models']<BR/>loop do<BR/> has_new = false<BR/> for dir in dirs<BR/> for file in Dir.glob dir + '/*'<BR/> time = File.ctime file<BR/> if time > latest_inserted<BR/> has_new = true<BR/> print 'got new' , file<BR/> break<BR/> end<BR/> end<BR/> break if has_new<BR/> end<BR/> if has_new<BR/> system_command = "kill -9 #{Process.pid}"<BR/> p 'running', system_command<BR/> system(system_command) # we are done<BR/> latest_inserted = Time.now<BR/> Process.kill!<BR/> Process.kill<BR/> Process::exit<BR/> end<BR/> sleep 0.2<BR/> end<BR/>} if ENV['RAILS_ENV'] == 'development' # ruby does it itself otherwise, I think. There may be a rails way to do this.<BR/><BR/>and then run the server inside a script that will start it automatically<BR/>like<BR/>run_forever.rb:<BR/>loop do<BR/> system ARGV.join(' ')<BR/> end<BR/>then<BR/>ruby run_forever.rb script/server -e development<BR/><BR/>then it works!Roger Packhttps://www.blogger.com/profile/01578246846716577925noreply@blogger.com