Sha256: a89f5fbc12fced558c9e6c08940910ee8bcd0701cf4d6c02a62048014cf0eb8d
Contents?: true
Size: 1021 Bytes
Versions: 26
Compression:
Stored size: 1021 Bytes
Contents
module Autoproj module Ops def self.watch_marker_path(root_dir) File.join(root_dir, '.autoproj', 'watch') end def self.watch_running?(root_dir) io = File.open(watch_marker_path(root_dir)) !io.flock(File::LOCK_EX | File::LOCK_NB) rescue Errno::ENOENT false ensure io.close if io end class WatchAlreadyRunning < RuntimeError; end def self.watch_create_marker(root_dir) io = File.open(watch_marker_path(root_dir), 'a+') if !io.flock(File::LOCK_EX | File::LOCK_NB) raise WatchAlreadyRunning, "autoproj watch is already running as PID #{io.read.strip}" end io.truncate(0) io.puts Process.pid io.flush rescue Exception io.close if io raise end def self.watch_cleanup_marker(io) FileUtils.rm_f io.path io.close end end end
Version data entries
26 entries across 26 versions & 1 rubygems