Commit 9cd500ab75aa740c19fc8d90d2ca2cc8fb65a331
- Date: Tue Feb 26 15:30:50 +0000 2008
- Committer: David A. Cuadrado (krawek@gmail.com)
- Author: David A. Cuadrado (krawek@gmail.com)
- Commit SHA1: 9cd500ab75aa740c19fc8d90d2ca2cc8fb65a331
- Tree SHA1: 37cda375808f5cf94e7943be267c7067a09a250e
Check if the tasklock file exists before to load rails environment
Commit diff
| |   |
| 1 | 1 | #!/usr/bin/env ruby |
| 2 | 2 | |
| 3 | | ENV["RAILS_ENV"] ||= "production" |
| 4 | | require File.dirname(__FILE__) + "/../config/environment" |
| 3 | require 'tmpdir' |
| 5 | 4 | require "fileutils" |
| 6 | 5 | |
| 7 | | LOCK_FILE_PATH = File.join(RAILS_ROOT, "tmp", "task_lockfile") |
| 8 | | |
| 6 | LOCK_FILE_PATH = File.join(Dir.tmpdir, "gitorious_task_lockfile") |
| 9 | 7 | ENV["PATH"] = "/usr/local/bin/:/opt/local/bin:#{ENV["PATH"]}" |
| 10 | 8 | |
| 9 | if File.exist?(LOCK_FILE_PATH) |
| 10 | $stderr.puts "Task lockfile '#{LOCK_FILE_PATH}' exists!" |
| 11 | exit(1) |
| 12 | end |
| 13 | |
| 14 | ENV["RAILS_ENV"] ||= "production" |
| 15 | require File.dirname(__FILE__) + "/../config/environment" |
| 16 | |
| 17 | |
| 11 | 18 | class TaskLockError < StandardError; end |
| 12 | 19 | |
| 13 | 20 | def with_lock(&block) |
| toggle raw diff |
--- a/script/task_performer
+++ b/script/task_performer
@@ -1,13 +1,20 @@
#!/usr/bin/env ruby
-ENV["RAILS_ENV"] ||= "production"
-require File.dirname(__FILE__) + "/../config/environment"
+require 'tmpdir'
require "fileutils"
-LOCK_FILE_PATH = File.join(RAILS_ROOT, "tmp", "task_lockfile")
-
+LOCK_FILE_PATH = File.join(Dir.tmpdir, "gitorious_task_lockfile")
ENV["PATH"] = "/usr/local/bin/:/opt/local/bin:#{ENV["PATH"]}"
+if File.exist?(LOCK_FILE_PATH)
+ $stderr.puts "Task lockfile '#{LOCK_FILE_PATH}' exists!"
+ exit(1)
+end
+
+ENV["RAILS_ENV"] ||= "production"
+require File.dirname(__FILE__) + "/../config/environment"
+
+
class TaskLockError < StandardError; end
def with_lock(&block) |