2022-12-15 04:00:54 +00:00
|
|
|
---
|
2023-08-26 15:30:51 +00:00
|
|
|
title: Module hilbish.jobs
|
2022-12-15 04:00:54 +00:00
|
|
|
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
|
2023-09-02 18:18:40 +00:00
|
|
|
|||
|
|
|
|
|----|----|
|
2023-12-04 00:54:00 +00:00
|
|
|
|<a href="#jobs.add">add(cmdstr, args, execPath)</a>|Creates a new job. This function does not run the job. This function is intended to be|
|
|
|
|
|<a href="#jobs.all">all() -> table[@Job]</a>|Returns a table of all job objects.|
|
|
|
|
|<a href="#jobs.disown">disown(id)</a>|Disowns a job. This simply deletes it from the list of jobs without stopping it.|
|
2023-09-02 18:18:40 +00:00
|
|
|
|<a href="#jobs.get">get(id) -> @Job</a>|Get a job object via its ID.|
|
2023-12-04 00:54:00 +00:00
|
|
|
|<a href="#jobs.last">last() -> @Job</a>|Returns the last added job to the table.|
|
2023-09-02 18:18:40 +00:00
|
|
|
|
2023-09-02 20:11:57 +00:00
|
|
|
<hr><div id='jobs.add'>
|
2023-09-02 18:18:40 +00:00
|
|
|
<h4 class='heading'>
|
|
|
|
hilbish.jobs.add(cmdstr, args, execPath)
|
|
|
|
<a href="#jobs.add" class='heading-link'>
|
|
|
|
<i class="fas fa-paperclip"></i>
|
|
|
|
</a>
|
|
|
|
</h4>
|
|
|
|
|
2023-12-04 00:54:00 +00:00
|
|
|
Creates a new job. This function does not run the job. This function is intended to be
|
|
|
|
used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs.
|
|
|
|
|
|
|
|
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
2023-12-04 00:54:00 +00:00
|
|
|
`string` **`cmdstr`**
|
|
|
|
String that a user would write for the job
|
|
|
|
|
|
|
|
`table` **`args`**
|
|
|
|
Arguments for the commands. Has to include the name of the command.
|
|
|
|
|
|
|
|
`string` **`execPath`**
|
|
|
|
Binary to use to run the command. Does not
|
|
|
|
|
|
|
|
#### Example
|
|
|
|
```lua
|
|
|
|
hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go')
|
|
|
|
````
|
2023-09-02 20:01:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr><div id='jobs.all'>
|
2023-09-02 18:18:40 +00:00
|
|
|
<h4 class='heading'>
|
2023-12-04 00:54:00 +00:00
|
|
|
hilbish.jobs.all() -> table[<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>]
|
2023-09-02 18:18:40 +00:00
|
|
|
<a href="#jobs.all" class='heading-link'>
|
|
|
|
<i class="fas fa-paperclip"></i>
|
|
|
|
</a>
|
|
|
|
</h4>
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-12-02 12:23:49 +00:00
|
|
|
Returns a table of all job objects.
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2023-09-02 20:01:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr><div id='jobs.disown'>
|
2023-09-02 18:18:40 +00:00
|
|
|
<h4 class='heading'>
|
|
|
|
hilbish.jobs.disown(id)
|
|
|
|
<a href="#jobs.disown" class='heading-link'>
|
|
|
|
<i class="fas fa-paperclip"></i>
|
|
|
|
</a>
|
|
|
|
</h4>
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-12-04 00:54:00 +00:00
|
|
|
Disowns a job. This simply deletes it from the list of jobs without stopping it.
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
2023-12-04 00:54:00 +00:00
|
|
|
`number` **`id`**
|
|
|
|
|
|
|
|
|
2023-09-02 20:01:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr><div id='jobs.get'>
|
2023-09-02 18:18:40 +00:00
|
|
|
<h4 class='heading'>
|
|
|
|
hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
|
|
|
<a href="#jobs.get" class='heading-link'>
|
|
|
|
<i class="fas fa-paperclip"></i>
|
|
|
|
</a>
|
|
|
|
</h4>
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-12-02 12:23:49 +00:00
|
|
|
Get a job object via its ID.
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2023-09-02 20:01:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<hr><div id='jobs.last'>
|
2023-09-02 18:18:40 +00:00
|
|
|
<h4 class='heading'>
|
|
|
|
hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
|
|
|
<a href="#jobs.last" class='heading-link'>
|
|
|
|
<i class="fas fa-paperclip"></i>
|
|
|
|
</a>
|
|
|
|
</h4>
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-12-04 00:54:00 +00:00
|
|
|
Returns the last added job to the table.
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2023-09-02 20:01:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
## Types
|
2023-09-02 20:11:57 +00:00
|
|
|
<hr>
|
|
|
|
|
2023-01-18 10:39:26 +00:00
|
|
|
## Job
|
|
|
|
The Job type describes a Hilbish job.
|
2023-09-02 20:11:57 +00:00
|
|
|
## Object 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.|
|
|
|
|
|
2023-01-18 10:39:26 +00:00
|
|
|
|
|
|
|
### 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.
|
|
|
|
|
2023-01-18 10:59:10 +00:00
|
|
|
#### stop()
|
|
|
|
Stops the job from running.
|
|
|
|
|