Method: Sensu::Server::Process#update_leader_lock

Defined in:
lib/sensu/server/process.rb

#update_leader_lockObject

Updates the Sensu server leader lock timestamp. The current leader ID is retrieved from Redis and compared with the leader ID of the current process to determine if it is still the Sensu server leader. If the current process is still the leader, the leader lock timestamp is updated. If the current process is no longer the leader (regicide), ‘resign_as_leader()` is called for cleanup, so there is not more than one leader.



979
980
981
982
983
984
985
986
987
988
989
990
# File 'lib/sensu/server/process.rb', line 979

def update_leader_lock
  @redis.get("leader") do |current_leader_id|
    if current_leader_id == leader_id
      @redis.set("lock:leader", create_lock_timestamp) do
        @logger.debug("updated leader lock timestamp")
      end
    else
      @logger.warn("another sensu server has been elected as leader")
      resign_as_leader
    end
  end
end