JobController
extends Controller
in package
uses
DispatchesJobs
Job management and monitoring controller
Handles background job operations including queue monitoring, lock management, cleanup operations, and library scanning job dispatching. Provides administrative tools for job system maintenance and troubleshooting.
Attributes
- #[Middleware]
- ['auth:sanctum', 'ability:' . \App\Models\TokenAbility::ACCESS_API->value, 'force.json']
- #[Prefix]
- 'jobs'
Table of Contents
Properties
Methods
- __construct() : mixed
- cleanupJobs() : JsonResponse
- Get job cleanup summary and optionally perform cleanup
- clearFailedJobs() : JsonResponse
- Clear failed jobs from the queue
- destroyJobLock() : JsonResponse
- Force remove a specific job lock
- getJobLock() : JsonResponse
- Get specific job lock information
- getJobLocks() : JsonResponse
- Get all job locks for a specific job type
- startLibraryScan() : JsonResponse
- Start a library scanning job
- denyWithStatus() : mixed
- gateCheckExecuteJob() : mixed
- gateCheckViewDashboard() : mixed
- noContent() : mixed
Properties
$jobCleanupService read-only
private
JobCleanupService
$jobCleanupService
Methods
__construct()
public
__construct(JobCleanupService $jobCleanupService) : mixed
Parameters
- $jobCleanupService : JobCleanupService
cleanupJobs()
Get job cleanup summary and optionally perform cleanup
public
cleanupJobs(Request $request) : JsonResponse
Analyzes the job system for stuck locks and failed jobs, providing a summary of issues found. Can perform actual cleanup when dry_run is set to false.
Parameters
- $request : Request
-
Request with optional dryRun boolean parameter
Tags
Attributes
- #[Post]
- '/cleanup'
- 'api.job.cleanup'
Return values
JsonResponseclearFailedJobs()
Clear failed jobs from the queue
public
clearFailedJobs(Request $request) : JsonResponse
Removes failed jobs older than the specified time threshold from the failed jobs table. Helps maintain system performance and storage efficiency.
Parameters
- $request : Request
-
Request with optional hoursOld and dryRun parameters
Tags
Attributes
- #[Post]
- '/failed'
- 'api.job.failed-cleanup'
Return values
JsonResponsedestroyJobLock()
Force remove a specific job lock
public
destroyJobLock(string $jobClass, string $jobId) : JsonResponse
Manually removes a job lock, typically used to clear stuck jobs that are preventing new instances from running. Use with caution as this can interfere with actively running jobs.
Parameters
- $jobClass : string
-
The job class name
- $jobId : string
-
The specific job instance ID to unlock
Tags
Attributes
- #[Delete]
- '/locks/{jobClass}/lock/{jobId}'
- 'api.job.lock-delete'
Return values
JsonResponsegetJobLock()
Get specific job lock information
public
getJobLock(string $jobClass, string $jobId) : JsonResponse
Retrieves detailed information about a specific job lock including its current state, time-to-live, and age for debugging purposes.
Parameters
- $jobClass : string
-
The job class name
- $jobId : string
-
The specific job instance ID
Tags
Attributes
- #[Get]
- '/locks/{jobClass}/lock/{jobId}'
- 'api.job.lock'
Return values
JsonResponsegetJobLocks()
Get all job locks for a specific job type
public
getJobLocks(string $jobId) : JsonResponse
Returns information about active job locks including TTL, age, and status. Used for monitoring job execution and identifying stuck or long-running jobs.
Parameters
- $jobId : string
-
The job identifier to get locks for
Tags
Attributes
- #[Get]
- '/locks'
- 'api.job.locks'
Return values
JsonResponsestartLibraryScan()
Start a library scanning job
public
startLibraryScan(Request $request) : JsonResponse
Dispatches a background job to scan a library for new media content. The job type (music or movie) is automatically determined by the library type.
Parameters
- $request : Request
-
Request containing the library slug in the route
Tags
Attributes
- #[Post]
- '/scanLibrary/{slug}'
- 'api.job.library-scan'
Return values
JsonResponsedenyWithStatus()
protected
denyWithStatus(string $message, int $status) : mixed
Parameters
- $message : string
- $status : int
gateCheckExecuteJob()
protected
gateCheckExecuteJob() : mixed
gateCheckViewDashboard()
protected
gateCheckViewDashboard() : mixed
noContent()
protected
noContent() : mixed