Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock update #3046

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/recipe/deploy/lock.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Locks deploy.


### deploy:unlock
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/lock.php#L19)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/lock.php#L20)

Unlocks deploy.




### deploy:is_locked
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/lock.php#L24)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/deploy/lock.php#L25)

Checks if deploy is locked.

Expand Down
6 changes: 4 additions & 2 deletions recipe/deploy/lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
$user = escapeshellarg(get('user'));
$locked = run("[ -f {{deploy_path}}/.dep/deploy.lock ] && echo +locked || echo $user > {{deploy_path}}/.dep/deploy.lock");
if ($locked === '+locked') {
$lockedUser = run("cat {{deploy_path}}/.dep/deploy.lock");
throw new GracefulShutdownException(
"Deploy locked.\n" .
"Deploy locked by $lockedUser.\n" .
"Execute \"deploy:unlock\" task to unlock."
);
}
Expand All @@ -24,7 +25,8 @@
task('deploy:is_locked', function () {
$locked = test("[ -f {{deploy_path}}/.dep/deploy.lock ]");
if ($locked) {
throw new GracefulShutdownException("Deploy is locked.");
$lockedUser = run("cat {{deploy_path}}/.dep/deploy.lock");
throw new GracefulShutdownException("Deploy is locked by $lockedUser.");
}
info('Deploy is unlocked.');
});
2 changes: 1 addition & 1 deletion tests/legacy/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testIsUnlockedExitsWithOneWhenDeployIsLocked()
$this->dep(self::RECIPE, 'deploy:is_locked');
$display = $this->tester->getDisplay();

self::assertStringContainsString('Deploy is locked.', $display);
self::assertStringContainsString('Deploy is locked by ', $display);
self::assertSame(1, $this->tester->getStatusCode());
}

Expand Down