Created
December 19, 2010 18:11
-
-
Save jeremywrowe/747539 to your computer and use it in GitHub Desktop.
autotest ruby script runner for rails (script/autotest), with matching autotest.rake file (lib/tasks/autotest.rake)
This file contains 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 characters
$here = File.expand_path(File.dirname(__FILE__)) | |
$rails_root = "#{$here}/../.." | |
$logs = "#{$rails_root}/logs/" | |
$script = "#{$rails_root}/script/autotest" | |
namespace :autotest do | |
desc "start autotest background task" | |
task :start do | |
`#{$script} start` | |
end | |
desc "stop autotest background task" | |
task :stop do | |
`#{$script} stop` | |
end | |
end |
This file contains 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 characters
#!/usr/bin/env ruby -wKU | |
require "fileutils" | |
include FileUtils | |
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + "/..") | |
AUTOTEST_PID = "#{RAILS_ROOT}/log/autotest.pid" | |
good_execution = false | |
if ARGV.size > 0 | |
if ARGV[0] =~ /start/i | |
puts "Starting autotest background runner" | |
cd RAILS_ROOT | |
`autotest &> #{RAILS_ROOT}/log/autotest.log &` | |
proc_pid = $?.pid + 1 | |
`echo #{proc_pid} > #{AUTOTEST_PID}` | |
good_execution = true | |
elsif ARGV[0] =~ /stop/i | |
puts "Stopping autotest background runner" | |
proc_pid = `cat #{AUTOTEST_PID}` | |
`kill #{proc_pid}` | |
good_execution = true | |
end | |
end | |
puts "usage: autotest [start|stop]" unless good_execution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment