NAME
bat - process manager
DESCRIPTION
Bat is the server that runs processes. It is mounted at /srv/proc/.
A process is a program started from a record.
Programs
A program is a javascript file. To start one, bat expands its includes with /srv/cc and evaluates the result as the body of a strict-mode function. The function is called once, with four names in scope:
- req(v, p, d)
is the kernel's req, with ns set to the process's namespace.
- mount(p, h)
is the kernel's mount, with ns set to the process's namespace.
- sub(f, cb, im = 1)
calls cb with the value of f(), and again each time that value changes. The value is recomputed when a resource that f read changes. A third argument of 0 skips the first call.
- tra(x)
tracks x.dis() so that it's called when the process ends, and returns x.
Records
A record describes a process to start:
/path/to/program args => /target/path1 name1 => /target/path2/ name2/
The first line is the program's path and its arguments. Each
following line binds target to name in the process's namespace,
in addition to the default binds.
Processes
Each process is a directory named by its pid. A pid is chosen by whoever starts the process, or generated by bat. When bat starts, it starts every saved process again from its record. The program runs from the beginning, with its fs/ as it was saved.
- /srv/proc/
- GET
List all processes.
- /srv/proc/new
- PUT
Create a process with a generated pid.
- Body
record
- Reply
Path of new process directory
- /srv/proc/{pid}/
- GET
List process resources.
- PUT
Create a process with this pid.
- Body
record
- DEL
Delete the process.
Each process has the following resources. A process reaches its own under proc/.
- exec
- GET
Read the record.
- PUT
Restart process.
- Body
record
- ns
- GET
Read the namespace.
- status
- GET
Read the status, one of: starting, started, closing or err.
- err
- GET
Read reason for failure when status is err.
- fs/
- GET
List program resources.
- ctl
- PUT
Send a command.
- Body
- close
End the process.
FILES
/etc/ns default binds