2022-12-15 04:00:54 +00:00
|
|
|
---
|
|
|
|
title: Interface hilbish.jobs
|
|
|
|
description: background job management
|
|
|
|
layout: doc
|
|
|
|
menu:
|
|
|
|
docs:
|
|
|
|
parent: "API"
|
|
|
|
---
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
|
|
|
|
Manage interactive jobs in Hilbish via Lua.
|
|
|
|
|
|
|
|
Jobs are the name of background tasks/commands. A job can be started via
|
|
|
|
interactive usage or with the functions defined below for use in external runners.
|
|
|
|
|
|
|
|
## Functions
|
|
|
|
### stop()
|
|
|
|
Stops the job from running.
|
|
|
|
|
|
|
|
### add(cmdstr, args, execPath)
|
|
|
|
Adds a new job to the job table. Note that this does not immediately run it.
|
|
|
|
|
2023-01-07 16:35:06 +00:00
|
|
|
### all() -> table\<<a href="#job" style="text-decoration: none;">Job</a>>
|
2022-12-15 04:00:54 +00:00
|
|
|
Returns a table of all job objects.
|
|
|
|
|
|
|
|
### disown(id)
|
|
|
|
Disowns a job. This deletes it from the job table.
|
|
|
|
|
2023-01-07 16:35:06 +00:00
|
|
|
### get(id) -> <a href="#job" style="text-decoration: none;">Job</a>
|
2022-12-15 04:00:54 +00:00
|
|
|
Get a job object via its ID.
|
|
|
|
|
2023-01-07 16:35:06 +00:00
|
|
|
### last() -> <a href="#job" style="text-decoration: none;">Job</a>
|
2022-12-15 04:00:54 +00:00
|
|
|
Returns the last added job from the table.
|
|
|
|
|
2023-01-07 16:57:34 +00:00
|
|
|
## Types
|
|
|
|
## Job
|
2023-01-07 18:25:57 +00:00
|
|
|
The Job type describes a Hilbish job.
|
2023-01-07 16:57:34 +00:00
|
|
|
### Properties
|
|
|
|
- `cmd`: The user entered command string for the job.
|
|
|
|
- `running`: Whether the job is running or not.
|
|
|
|
- `id`: The ID of the job in the job table
|
|
|
|
- `pid`: The Process ID
|
|
|
|
- `exitCode`: The last exit code of the job.
|
|
|
|
- `stdout`: The standard output of the job. This just means the normal logs of the process.
|
|
|
|
- `stderr`: The standard error stream of the process. This (usually) includes error messages of the job.
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
#### background()
|
|
|
|
Puts a job in the background. This acts the same as initially running a job.
|
|
|
|
|
|
|
|
#### foreground()
|
|
|
|
Puts a job in the foreground. This will cause it to run like it was
|
|
|
|
executed normally and wait for it to complete.
|
|
|
|
|
|
|
|
#### start()
|
|
|
|
Starts running the job.
|
|
|
|
|