I see that upon upgrades the .maintenance file is deleted, if present. Is it still a viable/correct way to put WP in maintenance mode?
.maintenance is a temporary file, not viable if you want to put your site in maintenance mode for a long time.
If you look at source the maintenance mode is maintained only if
$upgrading variable defined in the file is no older than 10 minutes.
.maintenance is a sort of lock file when WordPress is upgrading plugins, themes or itself, something that should not last more than 10 minutes.
Surely is possible to insert into that file something like:
$upgrading = time();
And in theory hold WordPress in maintenance mode, but once it is intended to be a temporary file, WordPress feels free to delete the file after a successfull update.
For a long-duration maintenance mode you need to use a different solution.
Here you'll find one.
Step 1: Create a file
.maintenance in the WP root directory like
Step 2: Put this code in the file
<?php $upgrading = time(); ?>
Step 3: Save the file. Then you can see the default maintenance message 'Briefly unavailable for scheduled maintenance. Check back in a minute.'.
Step 4: Once you have finished the repair or upgrade, then delete the code or the file
In case you want to have your own custom warning message, create a
maintenance.php file and placing it in your
/wp-content/ directory. WordPress uses this file to display during any forced maintenance period that you might have.