Server acts as a single entry point for all your worker nodes, as well as api clients. Essentially it is an HTTP REST API server with few methods that allow:
- Getting list of jobs
- Getting info about specific job
- Posting new jobs
- Updating existing jobs
- Removing jobs
Server uses process memory to store current list of jobs, and persists them onto disk each time a new job added/updated/removed/etc.
By default job list is persisted to this location: $HOME/nexrender/database.js
.
Can be overriden by providing NEXRENDER_DATABASE
env variable before launching the server.
You are able to change ordering of the jobs. By default nexrender is using oldest-first
(FIFO) type queue.
Can be changed by providing NEXRENDER_ORDERING
env vartiable before launching the server with such values:
oldest-first
- FIFO queue, oldest jobs will be rendered firstnewest-first
- LIFO queue, newest jobs will be rendered first, oldest will be rendered lastrandom
- Random access queue, jobs will be selected based on random counterpriority
- Jobs are selected based on their priority field (default 0), in case of a collision it will choose the oldest one.
If you want to monitor the status of all your running jobs, consider trying our SaaS solution, Nexrender Cloud, which offers enhanced visibility and a range of other cool features. Here is how it looks like:
- For binary usage:
npm install @nexrender/server -g
- For programmatic usage:
npm install @nexrender/server --save
Server can be used in 2 modes, binary and programmatic.
nexrender-server --port 3000 --secret=myapisecret
Binary has some options that can be used to configure it, for detailed list please check help
:
nexrender-server --help
Programmatic usage allows to embed the server directly into your application and use it as a controlled server:
const server = require('@nexrender/server')
const port = 3000
const secret = 'myapisecret'
server.listen(port, secret, () => {
console.log(`Server listening on port ${port}`)
})
Or, alternatively you can use createHandler
method, to integrate it with your custom http server:
const {createHandler} = require('@nexrender/server')
const handler = createHandler('myapisecret')
module.exports = (req, res) => handler(req, res)
Here is a short description of all api routes:
Gets list of all jobs, returns an array of json records.
Gets info about a specific job.
Creates a new job from json passed within a body.
Requires content-type=application/json
header to be present.
Updates an existing job, merges json provided by user with the one that exists in the server memory.
Requires content-type=application/json
header to be present.
Removes provided job from the server.
An internal method, used by worker to fetch a random job from the list, and start rendering. Probably should not be used by users, unless they know what are they doing.
An internal method, used by worker to fetch a random job with specific tags from the list, and start rendering. Tags name must be an alphanumeric. Probably should not be used by users, unless they know what are they doing.
Can serve as the health check for the service, does not require the secret header to be passed. Returns 200 always.