Commit a260e9e5c782276e71bc21e42621584a7b7b6b41
- Date: Sat Apr 12 03:51:45 +0000 2008
- Committer: David A. Cuadrado (krawek@gmail.com)
- Author: David A. Cuadrado (krawek@gmail.com)
- Commit SHA1: a260e9e5c782276e71bc21e42621584a7b7b6b41
- Tree SHA1: 3515d1956b033e1b555e3a37b5cafcfda8786627
lockfile for script/graph_generator
Commit diff
| |   |
| 1 | 1 | #!/usr/bin/env ruby |
| 2 | 2 | |
| 3 | require 'tmpdir' |
| 4 | require "fileutils" |
| 5 | |
| 6 | LOCK_FILE_PATH = File.join(Dir.tmpdir, "gitorious_graphgenerator_lockfile") |
| 7 | if File.exist?(LOCK_FILE_PATH) |
| 8 | $stderr.puts "Lockfile '#{LOCK_FILE_PATH}' exists!" |
| 9 | exit(1) |
| 10 | end |
| 11 | |
| 12 | FileUtils.touch(LOCK_FILE_PATH) |
| 13 | |
| 3 | 14 | ENV["RAILS_ENV"] ||= "production" |
| 4 | 15 | require File.dirname(__FILE__) + "/../config/environment" |
| 5 | 16 | |
| … | … | |
| 43 | 43 | # exit(1) |
| 44 | 44 | end |
| 45 | 45 | end |
| 46 | | log.info "Done with graph generation run" |
| 46 | log.info "Done with graph generation run" |
| 47 | |
| 48 | FileUtils.rm(LOCK_FILE_PATH) |
| toggle raw diff |
--- a/script/graph_generator
+++ b/script/graph_generator
@@ -1,5 +1,16 @@
#!/usr/bin/env ruby
+require 'tmpdir'
+require "fileutils"
+
+LOCK_FILE_PATH = File.join(Dir.tmpdir, "gitorious_graphgenerator_lockfile")
+if File.exist?(LOCK_FILE_PATH)
+ $stderr.puts "Lockfile '#{LOCK_FILE_PATH}' exists!"
+ exit(1)
+end
+
+FileUtils.touch(LOCK_FILE_PATH)
+
ENV["RAILS_ENV"] ||= "production"
require File.dirname(__FILE__) + "/../config/environment"
@@ -32,4 +43,6 @@ Repository.find(:all).each_with_index do |repository, index|
# exit(1)
end
end
-log.info "Done with graph generation run"
\ No newline at end of file
+log.info "Done with graph generation run"
+
+FileUtils.rm(LOCK_FILE_PATH) |