I know the importance of using a UPS to prevent the server from shutting down immediately. How to listen for such an event in a Java application?
Say that my UPS will continue to operate under full load for 5 minutes when the power stops. The server will continue to work, but how will my application know that its time to start closing everything correctly?
This particular application mainly deals with client transactions with the database. I mainly worry about corrupted data in the case when the server expires immediately in the middle of mysql transactions. Are the points below appropriately coping with a power situation?
- The power turns off. UPS operation mode. The app detects this.
- The application somehow blocks all incoming requests (any suggestions on this subject will be useful)
- Within a few minutes, all transactions that were in progress should be completed.
- Shutdown
- If the battery runs out, the server will go down ... wait to recover.
Is there a way to automatically restart the server and applications when power is restored, or does it need to be done manually?
source share