If Your application can get data from more than one database You can use cascading replication for load balancing(One App get data from multiple bases) but only in case when it's synchronous replication(in case of cascading rep. it's heavy).
In case of M1 fail You can do Python script that will place S1 as master(including updating port, config, and connecting with S2). It's not hard, with Python You can do it in about one hour. Other option is Python script that will restore M1 with data from S1, use Python library: PSYCOPG2