@@ -578,13 +578,6 @@ protected function run_job($job)
578578 $ this ->log ->error ('failed to create tmp file ' );
579579 throw new Exception ('failed to create tmp file ' );
580580 }
581- $ command = $ this ->job_command ($ job , $ error_log_file );
582- $ this ->log ->debug_app ('preparing for worker ' , ['job_id ' => $ job ->id , 'command ' => $ command ]);
583-
584- $ spec = [
585- 1 => ['pipe ' , 'w ' ], // stdout
586- 2 => ['pipe ' , 'w ' ], // stderr
587- ];
588581
589582 // Resolve path every time to support atomic deployment.
590583 $ wp_path = realpath ($ this ->wp_base_path );
@@ -593,6 +586,14 @@ protected function run_job($job)
593586 throw new Exception ('failed to resolve path ' );
594587 }
595588
589+ $ command = $ this ->job_command ($ job , $ error_log_file , $ wp_path );
590+ $ this ->log ->debug_app ('preparing for worker ' , ['job_id ' => $ job ->id , 'command ' => $ command ]);
591+
592+ $ spec = [
593+ 1 => ['pipe ' , 'w ' ], // stdout
594+ 2 => ['pipe ' , 'w ' ], // stderr
595+ ];
596+
596597 $ process = proc_open ($ command , $ spec , $ pipes , $ wp_path );
597598
598599 if ($ process === false ) {
@@ -632,11 +633,11 @@ protected function run_job($job)
632633 $ this ->hooks ->run ('Runner.run_job.started ' , $ worker , $ job );
633634 }
634635
635- protected function job_command ($ job , $ error_log_file )
636+ protected function job_command ($ job , $ error_log_file, $ wp_path )
636637 {
637638 $ siteurl = $ job ->get_site_url ();
638639
639- $ command = "php -d error_log= $ error_log_file $ this ->wpcli_path --no-color cavalcade run $ job ->id " ;
640+ $ command = "php -d error_log= $ error_log_file $ this ->wpcli_path --path= $ wp_path -- no-color cavalcade run $ job ->id " ;
640641
641642 if ($ siteurl ) {
642643 $ command .= ' --url= ' . escapeshellarg ($ siteurl );
0 commit comments