Class: Uc::Lock
- Inherits:
-
Object
- Object
- Uc::Lock
- Defined in:
- lib/uc/lock.rb
Instance Attribute Summary collapse
-
#app_dir ⇒ Object
readonly
Returns the value of attribute app_dir.
Instance Method Summary collapse
- #acquire ⇒ Object
-
#initialize(app_dir) ⇒ Lock
constructor
A new instance of Lock.
Constructor Details
#initialize(app_dir) ⇒ Lock
Returns a new instance of Lock.
6 7 8 |
# File 'lib/uc/lock.rb', line 6 def initialize(app_dir) @app_dir = app_dir end |
Instance Attribute Details
#app_dir ⇒ Object (readonly)
Returns the value of attribute app_dir.
5 6 7 |
# File 'lib/uc/lock.rb', line 5 def app_dir @app_dir end |
Instance Method Details
#acquire ⇒ Object
10 11 12 13 14 15 |
# File 'lib/uc/lock.rb', line 10 def acquire Dir.chdir app_dir do lock_acquired = File.new("tmp/.uc.lock", "a+").flock( File::LOCK_NB | File::LOCK_EX ) raise ::Uc::Error,"another uc process is already running" if not lock_acquired end end |