44 lines
1.1 KiB
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;
use Deployer\Exception\RunException;
2017-01-19 11:10:30 +07:00
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) {
2017-01-19 11:10:30 +07:00
throw new GracefulShutdownException(
2016-11-19 15:13:32 +07:00
"Deploy locked.\n" .
2020-04-25 23:00:08 +03:00
sprintf("Execute \"deploy:unlock\" task to unlock.")
2016-11-19 15:13:32 +07:00
);
} else {
2020-04-25 23:00:08 +03:00
run("echo \"{{user}}\" > {{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
});
desc('Check if deploy is unlocked');
task('deploy:is-unlocked', function () {
$locked = test("[ -f {{deploy_path}}/.dep/deploy.lock ]");
if ($locked) {
writeln( 'Deploy is currently locked.');
throw new GracefulShutdownException();
}
writeln( 'Deploy is currently unlocked.');
});