diff --git a/README.md b/README.md
index 536d946..06c61be 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,7 @@ An elegant debug assistant for the hyperf framework.
- [x] guzzle
- [x] cache
- [x] rpc server/client
+- [x] schedule
## Installation
diff --git a/publish/telescope.php b/publish/telescope.php
index c015640..e162698 100644
--- a/publish/telescope.php
+++ b/publish/telescope.php
@@ -28,6 +28,7 @@
'guzzle' => env('TELESCOPE_ENABLE_GUZZLE', false),
'cache' => env('TELESCOPE_ENABLE_CACHE', false),
'rpc' => env('TELESCOPE_ENABLE_RPC', false),
+ 'schedule' => env('TELESCOPE_ENABLE_SCHEDULE', true),
],
'recording' => true,
'timezone' => env('TELESCOPE_TIMEZONE', 'Asia/Shanghai'),
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php
index 5d780e4..92dfbee 100644
--- a/resources/views/index.blade.php
+++ b/resources/views/index.blade.php
@@ -117,6 +117,12 @@
Commands
+
+
+
+ Schedule
+
+
diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php
index 0ad5bfd..a27fad7 100644
--- a/src/ConfigProvider.php
+++ b/src/ConfigProvider.php
@@ -41,6 +41,7 @@ public function __invoke(): array
Contract\PrunableRepository::class => fn ($container) => $container->get(Contract\EntriesRepository::class),
],
'listeners' => [
+ Listener\CronEventListener::class,
Listener\CommandListener::class,
Listener\DbQueryListener::class,
Listener\ExceptionHandlerListener::class,
diff --git a/src/Controller/ScheduleController.php b/src/Controller/ScheduleController.php
new file mode 100644
index 0000000..57645da
--- /dev/null
+++ b/src/Controller/ScheduleController.php
@@ -0,0 +1,27 @@
+telescopeConfig->isEnable('schedule')) {
+ return;
+ }
+
+ TelescopeContext::getOrSetBatch();
+
+ $output = match (true) {
+ $event instanceof Event\AfterExecute => 'success',
+ $event instanceof Event\FailToExecute => '[fail]' . (string) $event->getThrowable(),
+ default => '',
+ };
+
+ Telescope::recordSchedule(IncomingEntry::make([
+ 'command' => $event->crontab->getName(),
+ 'description' => $event->crontab->getMemo(),
+ 'expression' => $event->crontab->getRule(),
+ 'timezone' => $event->crontab->getTimezone(),
+ 'user' => '',
+ 'output' => $output,
+ ]));
+ }
+}
diff --git a/src/Listener/RegisterRoutesListener.php b/src/Listener/RegisterRoutesListener.php
index 5037bab..1b321fb 100644
--- a/src/Listener/RegisterRoutesListener.php
+++ b/src/Listener/RegisterRoutesListener.php
@@ -57,6 +57,9 @@ public function process(object $event): void
Router::post('/commands', [Controller\CommandsController::class, 'index']);
Router::get('/commands/{id}', [Controller\CommandsController::class, 'show']);
+ Router::post('/schedule', [Controller\ScheduleController::class, 'index']);
+ Router::get('/schedule/{id}', [Controller\ScheduleController::class, 'show']);
+
Router::delete('/entries', [Controller\EntriesController::class, 'destroy']);
Router::post('/events', [Controller\EventsController::class, 'index']);
diff --git a/src/Telescope.php b/src/Telescope.php
index 67df9e9..a5ad4e2 100644
--- a/src/Telescope.php
+++ b/src/Telescope.php
@@ -95,6 +95,11 @@ public static function recordEvent(IncomingEntry $entry): void
static::record(EntryType::EVENT, $entry);
}
+ public static function recordSchedule(IncomingEntry $entry): void
+ {
+ static::record(EntryType::SCHEDULE, $entry);
+ }
+
public static function recordException(IncomingEntry $entry): void
{
static::record(EntryType::EXCEPTION, $entry);