Bånder

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

$jobCleanupService  : JobCleanupService

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

Methods

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
response

array{ stuck_locks: array{ count: int, locks: array<array{ key: string, ttl: int, age_hours: int|string }> }, failed_jobs: array<array{ id: int, uuid: string, connection: string, queue: string, payload: string, exception: string, failed_at: string }>, dry_run: boolean }

Attributes
#[Post]
'/cleanup'
'api.job.cleanup'
Return values
JsonResponse

clearFailedJobs()

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
response

array{ success: boolean, message: string }

Attributes
#[Post]
'/failed'
'api.job.failed-cleanup'
Return values
JsonResponse

destroyJobLock()

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
response

array{ success: boolean, message: string }

Attributes
#[Delete]
'/locks/{jobClass}/lock/{jobId}'
'api.job.lock-delete'
Return values
JsonResponse

getJobLock()

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
throws
CouldNotFindJobException

When job lock is not found

response

array{ key: string, ttl: int, age_hours: int|string, exists: boolean }

Attributes
#[Get]
'/locks/{jobClass}/lock/{jobId}'
'api.job.lock'
Return values
JsonResponse

getJobLocks()

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
response

array<array{ key: string, ttl: int, age_hours: int|string, exists: boolean }>

Attributes
#[Get]
'/locks'
'api.job.locks'
Return values
JsonResponse

startLibraryScan()

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
throws
CouldNotFindJobException

When library is not found

throws
AuthorizationException

When user lacks job execution privileges

response

array{ message: string }

status

202

Attributes
#[Post]
'/scanLibrary/{slug}'
'api.job.library-scan'
Return values
JsonResponse

denyWithStatus()

protected denyWithStatus(string $message, int $status) : mixed
Parameters
$message : string
$status : int

gateCheckExecuteJob()

protected gateCheckExecuteJob() : mixed

gateCheckViewDashboard()

protected gateCheckViewDashboard() : mixed

        
On this page

Search results