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 () {
|
2017-08-12 18:06:21 +03:00
|
|
|
$locked = test("[ -f {{deploy_path}}/.dep/deploy.lock ]");
|
2016-11-19 15:13:32 +07:00
|
|
|
|
|
|
|
if ($locked) {
|
2017-04-05 15:02:19 +02:00
|
|
|
$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" .
|
2020-03-06 10:49:07 +01:00
|
|
|
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 () {
|
2017-01-12 11:50:46 +07:00
|
|
|
run("rm -f {{deploy_path}}/.dep/deploy.lock");//always success
|
2016-11-19 15:13:32 +07:00
|
|
|
});
|