Method: #semaphore
- Defined in:
- lib/semaphore.rb
#semaphore(semaphore_key) ⇒ Object
Creates a pid-file semaphore to govern global execution
Attributes
-
semaphore_key- string to name semaphore
Returns
true if semaphore created, false if already exists
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/semaphore.rb', line 10 def semaphore(semaphore_key) semaphore_dir = "#{BrpmAuto.params.automation_results_dir}/semaphores" semaphore_name = "#{semaphore_key}.pid" FileUtils.mkdir(semaphore_dir) unless File.exist?(semaphore_dir) return false if File.exist?(File.join(semaphore_dir, semaphore_name)) fil = File.open(File.join(semaphore_dir, semaphore_name), "w+") fil.puts BrpmAuto. fil.flush fil.close return true end |