Mathias Brodala 0acbb4c6fb Improve lock message
Prefix launcher script and append current stage.
2017-04-05 15:02:19 +02:00

32 lines
885 B
PHP

<?php
/* (c) Anton Medvedev <anton@medv.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
use Deployer\Exception\GracefulShutdownException;
desc('Lock deploy');
task('deploy:lock', function () {
$locked = run("if [ -f {{deploy_path}}/.dep/deploy.lock ]; then echo 'true'; fi")->toBool();
if ($locked) {
$stage = input()->hasArgument('stage') ? ' ' . input()->getArgument('stage') : '';
throw new GracefulShutdownException(
"Deploy locked.\n" .
sprintf('Execute "dep deploy:unlock%s" to unlock.', $stage)
);
} else {
run("touch {{deploy_path}}/.dep/deploy.lock");
}
});
desc('Unlock deploy');
task('deploy:unlock', function () {
run("rm -f {{deploy_path}}/.dep/deploy.lock");//always success
});