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

Version Path
autoproj-2.14.0 lib/autoproj/ops/watch.rb
autoproj-2.13.0 lib/autoproj/ops/watch.rb
autoproj-2.12.1 lib/autoproj/ops/watch.rb
autoproj-2.12.0 lib/autoproj/ops/watch.rb
autoproj-2.11.0 lib/autoproj/ops/watch.rb
autoproj-2.10.2 lib/autoproj/ops/watch.rb
autoproj-2.10.1 lib/autoproj/ops/watch.rb
autoproj-2.10.0 lib/autoproj/ops/watch.rb
autoproj-2.9.0 lib/autoproj/ops/watch.rb
autoproj-2.8.8 lib/autoproj/ops/watch.rb
autoproj-2.8.7 lib/autoproj/ops/watch.rb
autoproj-2.8.6 lib/autoproj/ops/watch.rb
autoproj-2.8.5 lib/autoproj/ops/watch.rb
autoproj-2.8.5.b1 lib/autoproj/ops/watch.rb
autoproj-2.8.4 lib/autoproj/ops/watch.rb
autoproj-2.8.3 lib/autoproj/ops/watch.rb
autoproj-2.8.2 lib/autoproj/ops/watch.rb
autoproj-2.8.1 lib/autoproj/ops/watch.rb
autoproj-2.8.0 lib/autoproj/ops/watch.rb
autoproj-2.7.1 lib/autoproj/ops/watch.rb