Method: Roby::Application#lock_log_dir

Defined in:
lib/roby/app.rb

#lock_log_dirObject



1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
# File 'lib/roby/app.rb', line 1053

def lock_log_dir
    final_lock_path = File.join(log_dir, LOCK_FILE_EXT)
    temp_lock_path = "#{final_lock_path}.tmp"
    lock_file = File.open(temp_lock_path, File::RDWR | File::CREAT, 0o644)
    unless lock_file.flock(File::LOCK_EX | File::LOCK_NB)
        raise "could not lock the log directory on setup"
    end

    File.rename(temp_lock_path, final_lock_path)
    @lock_file = lock_file
end