我有一个 PHP Deployer 任务来递归地更改部署路径中所有内容的文件所有者:
task('set_owner', function () {
run("chown -R someuser:www-data {{deploy_path}}");
});
after('deploy:failed', 'deploy:unlock'); // Unlock after failed deploy
Operation not permitted
Deployer 未能完成此任务,因为此 commond 给出了一些错误。很公平,因为这些文件无论如何都不需要更改。所以我添加2>&1 | grep -v 'Operation not permitted'
以防止错误显示:
task('set_owner', function () {
run("chown -R deployer:www-data {{deploy_path}} 2>&1 | grep -v 'Operation not permitted'");
});
after('deploy:failed', 'deploy:unlock'); // Unlock after failed deploy
但是,当我运行它时,Deployer 仍然无法完成此任务:
➤ Executing task set_owner
[myapp.com] > chown -R someuser:www-data /var/www/myapp.com 2>&1 | grep -v 'Operation not permitted'
➤ Executing task deploy:failed
• done on [myapp.com]
✔ Ok [1ms]
➤ Executing task deploy:unlock
[myapp.com] > rm -f /var/www/myapp.com/.dep/deploy.lock
• done on [myapp.com]
✔ Ok [1s 364ms]
In Client.php line 103:
[Deployer\Exception\RuntimeException (1)]
The command "chown -R someuser:www-data /var/www/myapp.com 2>&
1 | grep -v 'Operation not permitted'" failed.
Exit Code: 1 (General error)
在这种情况下,有没有办法防止 Deployer 失败?