Class: Spring::Env
- Inherits:
-
Object
- Object
- Spring::Env
- Defined in:
- lib/spring/env.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #app_name ⇒ Object
-
#initialize(root = nil) ⇒ Env
constructor
A new instance of Env.
- #pid ⇒ Object
- #pidfile_path ⇒ Object
- #server_running? ⇒ Boolean
- #socket_name ⇒ Object
- #socket_path ⇒ Object
- #tmp_path ⇒ Object
- #version ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/spring/env.rb', line 11 def root @root end |
Instance Method Details
#app_name ⇒ Object
46 47 48 |
# File 'lib/spring/env.rb', line 46 def app_name root.basename end |
#pid ⇒ Object
39 40 41 42 43 44 |
# File 'lib/spring/env.rb', line 39 def pid pidfile_path.exist? ? pidfile_path.read.to_i : nil rescue Errno::ENOENT # This can happen if the pidfile is removed after we check it # exists end |
#pidfile_path ⇒ Object
35 36 37 |
# File 'lib/spring/env.rb', line 35 def pidfile_path tmp_path.join("spring.pid") end |
#server_running? ⇒ Boolean
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/spring/env.rb', line 50 def server_running? if pidfile_path.exist? pidfile = pidfile_path.open('r') !pidfile.flock(File::LOCK_EX | File::LOCK_NB) else false end ensure if pidfile pidfile.flock(File::LOCK_UN) pidfile.close end end |
#socket_name ⇒ Object
31 32 33 |
# File 'lib/spring/env.rb', line 31 def socket_name socket_path.to_s end |
#socket_path ⇒ Object
27 28 29 |
# File 'lib/spring/env.rb', line 27 def socket_path tmp_path.join("spring") end |
#tmp_path ⇒ Object
21 22 23 24 25 |
# File 'lib/spring/env.rb', line 21 def tmp_path path = default_tmp_path FileUtils.mkdir_p(path) unless path.exist? path end |