32 lines
882 B
PHP
Raw Normal View History

2016-11-19 15:13:32 +07:00
<?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;
2017-01-19 11:10:30 +07:00
use Deployer\Exception\GracefulShutdownException;
2016-11-19 15:13:32 +07:00
desc('Lock deploy');
task('deploy:lock', function () {
$locked = test("[ -f {{deploy_path}}/.dep/deploy.lock ]");
2016-11-19 15:13:32 +07:00
if ($locked) {
$stage = input()->hasArgument('stage') ? ' ' . input()->getArgument('stage') : '';
2017-01-19 11:10:30 +07:00
throw new GracefulShutdownException(
2016-11-19 15:13:32 +07:00
"Deploy locked.\n" .
sprintf('Execute "'. Deployer::getCalledScript() .' deploy:unlock%s" to unlock.', $stage)
2016-11-19 15:13:32 +07:00
);
} else {
2016-11-19 15:53:31 +07:00
run("touch {{deploy_path}}/.dep/deploy.lock");
2016-11-19 15:13:32 +07:00
}
});
desc('Unlock deploy');
task('deploy:unlock', function () {
run("rm -f {{deploy_path}}/.dep/deploy.lock");//always success
2016-11-19 15:13:32 +07:00
});