2014-10-31

Ruby File Lock For Check Duplicate Running

hmmm....just code :)
$file_lock = [File.open("#{__dir__}/lock_me")]
$file_lock << $file_lock[0].flock(File::LOCK_EX|File::LOCK_NB)
unless $file_lock[1] == 0
  puts "Yoooo...Duplicate Server Running (fail of file lock check)"
  abort
else
  puts "FILE LOCK CHECK OKAY!"
end

沒有留言:

張貼留言