I have 4 cloud instances. First is a load balancer (LB), and then 2 instances with the identical setup holding the application code (APP1 & APP2). And finally, I have a database instance (DB).
- DB: MySQL
- Web service: Nginx
LB will route all requests to APP1 only. If APP1 goes down, LB will route requests to APP2.
I want to write a shell script that will execute only if LB is not routing requests to it.
So, I would have a shall script called run.sh on both, APP1 and APP2. If and only if LB routes requests to APP1, would run.sh on APP2 execute via cron.
Any idea how I can figure out, from APP2, if LB is routing requests to it?