mgsmus
Hocam Selamlar,
Bir noktaya kadar getirdim. Ama sunucu ile local bilgisayarım arasında kilit isim farkı oluşuyor.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Str;
class ScheduleList extends Command
{
protected $signature = 'schedule:list';
protected $description = 'List when scheduled commands are executed.';
/**
* @var Schedule
*/
protected Schedule $schedule;
/**
* ScheduleList constructor.
*
* @param Schedule $schedule
*/
public function __construct(Schedule $schedule)
{
parent::__construct();
$this->schedule = $schedule;
}
/**
* Execute the console command.
*/
public function handle()
{
$events = array_map(function ($event) {
return [
'cron' => $event->expression,
'command' => static::fixupCommand($event->command),
'sha1' => $event->mutexName(),
'exists' => $event->mutex->exists($event)
];
}, $this->schedule->events());
$json = json_encode($events);
$this->line($json);
}
/**
* If it's an artisan command, strip off the PHP
*
* @param $command
* @return string
*/
protected static function fixupCommand($command): string
{
$parts = explode(' ', $command);
if (count($parts) > 2 && (strstr('artisan', $parts[1]))){
array_shift($parts);
}
return implode(' ', $parts);
}
}
class Schedulelist extends Integration
{
public function runTheIntegration($database = 'mysql', $integrationOptions = []): Factory|View|Application
{
Artisan::call('schedule:list');
$events = json_decode(Artisan::output());
$databaseControl = DB::table('cache')
->where('key', 'LIKE', '%schedule%')
->get();
$databaseControlCounter = count($databaseControl);
$eventCounter = count($events);
for ($j = 0; $j < $eventCounter; $j++) {
$events[$j]->command = trim(explode('artisan', $events[$j]->command)[1]);
if (str_starts_with($events[$j]->command, '"') || str_starts_with($events[$j]->command, "'")) {
$events[$j]->command = trim(substr($events[$j]->command, 1, strlen($events[$j]->command)));
}
$events[$j]->status = 'Yok';
$events[$j]->statusColor = 'red';
for ($i = 0; $i < $databaseControlCounter; $i++) {
if (strstr($databaseControl[$i]->key, $events[$j]->sha1) !== false) {
$events[$j]->status = 'Var';
$events[$j]->statusColor = 'green';
}
}
}
return view("schedule-list", compact("events"));
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/v/bs-3.3.7/jq-3.3.1/jszip-2.5.0/dt-1.10.20/b-1.6.1/b-html5-1.6.1/b-print-1.6.1/r-2.2.3/sc-2.0.1/sp-1.0.1/datatables.min.css"/>
<title>Schedule List</title>
</head>
<body>
<div class="container-fluid">
<div class="my-current">
<table id="MyCurrent" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>cron</th>
<th>command</th>
<th>sha1</th>
<th>exists</th>
<th>durum</th>
</tr>
</thead>
<tbody>
@foreach ($events as $event)
<tr>
<td>{{ $event->cron }}</td>
<td>{{ $event->command }}</td>
<td>{{ $event->sha1 }}</td>
<td>{{$event->exists}}</td>
<td style="text-align:center;
background-color: {{$event->statusColor }};
color: white"> {{$event->status }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</body>
</html>
Aynı kod localde = > framework\schedule-66a7698869f407bd269354358ec048ef346857da sonucunu veriyor. Eşleşme de sağlanıyor.
Sunucu tarafında gelen data => framework/schedule-55125a887614e8142825eee138545e858c0e1991
BuildCommand da çalıştırdım:
Local : start /b cmd /v:on /c "("C:\xampp\php\php.exe" "artisan" integration:Customer musteri1-siparis & "C:\xampp\php\php.exe" "artisan" schedule:finish "framework\schedule-66a7698869f407bd269354358ec048ef346857da" !ERRORLEVEL!) > "NUL" 2>&1"
Server: '/opt/plesk/php/8.1/bin/php-cgi' 'artisan' integration:Customer musteri1-siparis > '/dev/null' 2>&1 ; '/opt/plesk/php/8.1/bin/php-cgi' 'artisan' schedule:finish "framework/schedule-55125a887614e8142825eee138545e858c0e1991" "$?") > '/dev/null' 2>&1 &