jeudi 10 mai 2018

Laravel chained jobs as array not working. Attempt to assign property of non-object

I'm trying to loop over multiple servers that need to run 1 at a time using Laravel's withChain. The first job completes just fine but the data I'm passing within the chained jobs gives me the

Attempt to assign property of non-object

When I log out the initial dispatched data it looks just like the constructed data in my array so I'm not sure what I'm doing wrong.

$new_jobs_array = [];
foreach ($this->wasRequest->nodes->sortByDesc('pivot.node_type') as $node) {
        if ($node->pivot->node_type != 'WAS_DMGR')
        {
            $snode        = strtolower($node->hostname);
            $shortname    = strtok($snode, '.');
            $fileName     = strtolower($mnemonic).'_'.$shortname.'_'.$reqId.'.json';
            $sourceJsonPath = base_path() . "/json/was/" . $fileName;

            $new_job = 'new BootStrapWasNode('. $node .', '. $this->wasRequest .', '.$sourceJsonPath.')';

            array_push($new_jobs_array, $new_job);
        } else {
            $dmgr_node = $node;
        }
    }
    //Log::info($new_jobs_array);
    $dmgr_node_sname    = strtok($this->wasRequest->nodes->where('pivot.node_type', 'WAS_DMGR')->pluck('hostname')[0], '.');
    $fileName     = strtolower($mnemonic).'_'.$dmgr_node_sname.'_'.$reqId.'.json';
    $sourceJsonPath = base_path() . "/json/was/" . $fileName;

    $this->wasRequest->status = 'Bootstrapping Nodes';
    $this->wasRequest->save();
    //Log::info("DMGR-------------------".$dmgr_node.", ".$this->wasRequest.", ".$sourceJsonPath);
    BootStrapWasNode::withChain($new_jobs_array)->dispatch($dmgr_node, $this->wasRequest, $sourceJsonPath);

I can attach the log view if needed but there is a lot of data for each node. The issue is with the $new_nodes_array, the initial dispatch($dmgr_node,$this->wasRequest,$sourceJsonPath) completes without issue.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2rzOjnr
via IFTTT

Aucun commentaire:

Enregistrer un commentaire