How does trigger file in recovery.conf work?
Any reliable failover scenario requires a third party, sometimes called a "witness", "arbitrator", "cluster monitor", "cluster manager" etc. to detect failure of one member and initiate a failover. This process ideally resides on a network separate from the one that connects cluster members to each other. It "pings" node(s) that are deemed to be masters or active nodes and triggers failover when they don't respond within the timeout threshold. In your case this monitor will create trigger_file to initiate the failover.