Module: Rb2db
- Defined in:
- lib/rb2db.rb,
lib/rb2db/version.rb
Constant Summary collapse
- VERSION =
"0.2.1"
Class Method Summary collapse
Class Method Details
.pid_check ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rb2db.rb', line 4 def self.pid_check # PID file to use. pid_file = (ENV['XDG_RUNTIME_DIR'] || '/tmp') + '/.rb2db.pid' # If the file exists, check if the pid inside is still running if (pid = File.file?(pid_file) && File.read(pid_file)) if pid.to_i > 0 && `ps -p #{pid}`.include?(pid) abort "[!] rb2db already running on pid #{pid}" end end # Write new PID file. File.write(pid_file, $$) end |