Keep in mind that "large server farms" are designed to not ever shutdown unless they're obliged to do so. That means it is a possible but far far remote event, and when it happens you're really in a hurry. Every other use case, such as shutting down a rack or doing work on power lines, will be planned in advance as much as possible.
You will actually be in an hurry when things go really wrong.
For example the generators run out of fuel (usually they'll keep at least one full day of reserve and have contracts to get re supplied in time, so we're talking about big disaster here) or similar events, you'll know it will be happening with hours of time to shutdown things. Or the HVAC system completely fails, then you have mere minutes to shutdown everything before temperatures raise too much.
I'm not an expert here, being on the other side of the barricade (customer of data centers), but I think they'll have systems in place to command shutdown of all the systems they control, and they will simply cut power to customer's systems they can't control and correctly shutdown.
The farm will be eventually powered up again one zone at a time, one rack at a time, when all systems are back online and ready to go full capacity (UPSes, generators, HVAC, etc).
When they have full control of the systems (i.e., not customer ones but private farms) they will usually bring AC gradually to all circuits, and servers will either power up automatically (if configured to do so, and many servers can even have a setting like "power up after a random time of max X minutes") or they will be commanded to power up via lights-out management like IPMI or similar systems.