Last active
September 28, 2015 11:18
Revisions
-
samg revised this gist
Dec 11, 2014 . 1 changed file with 6 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 @@ -1,11 +1,13 @@ require 'fileutils' begin path_to_lock_file = '/tmp/lock.lock' File.new(path_to_lock_file, File::CREAT|File::EXCL) # raise if file already exits begin system *ARGV ensure FileUtils.rm path_to_lock_file end rescue Errno::EEXIST warn "Job currently running, exiting." end -
samg created this gist
Dec 4, 2011 .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,11 @@ def self.with_lock_file path_to_lock_file File.new(path_to_lock_file, File::CREAT|File::EXCL) # raise if file already exits log "Checking for commits" begin yield ensure FileUtils.rm path_to_lock_file end rescue Errno::EEXIST log "Job currently running, exiting." end