Laravel에 간단한 배포자를 구축하려고합니다. WebHook을 받고, 배포를 수행하고, 배포에 대한 정보를 저장합니다.
나는 다음과 같은 수행 할 Laravel 5.2 작업 디스패처를 사용하고 다음 exec()
기능의
public function deploy()
{
$result = 0;
$output = array();
exec('cd ' . $this->deploymentMapping->full_file_path . '; git pull', $output, $result);
return array(
'result' => $result,
'output' => $this->outputToString($output)
);
}
나의 이해이 직접 오류를 덤프하지 않아야하지만, $output
에 저장하는 것입니다.
그러나 명령 줄에서 내 서버의 php artisan queue:work
을 실행하면 작업 디스패처를 테스트하기 위해 즉시 명령 줄 출력에 fatal: Not a git repository (or any of the parent directories): .git
이 덤프됩니다. 이 자식 오류는 올바른이지만, 마치 exec()
이 오류를 던진 것처럼 작업이 "실패"합니다. 이 올바른지? 다음과 같이 내 직업은 자신의 방법으로 오류를보고해야한다 :
public function handle()
{
$deploymentAttempt = new DeploymentAttempt();
$deploymentAttempt->deployment_id = $this->deploymentID;
$gitResponse = $this->deployer->deploy(); //the above function
$deploymentAttempt->success = !($gitResponse['result'] > 0);
$deploymentAttempt->message = $gitResponse['output'];
$deploymentAttempt->save();
}
감사를 따를 수
2>&1
의 작동 방식에 대한 자세한 내용을 알고! 작업을 실패하게 만드는 오류는 실제로 StdOut/StdErr에서이 문제가 아니 었습니다. 실제로'$ deploymentAttempt-> successful'보다는'$ deploymentAttempt-> success'를 쓰는 것이 었습니다. 나는 딩고 야. 당신의 도움을 주셔서 감사합니다 :) – k4kuz0