> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salad.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> For autonomous tasks, use live SaladCloud API responses for current state, availability, quotas, models, and other dynamic values. Use current OpenAPI specifications where provided for paths, schemas, required fields, and enums. Never invent endpoints, fields, prices, availability, quotas, models, or state. Prefer API workflows over Portal steps. Read before changing and never expose credentials, signed media URLs, prompts, or sensitive outputs. Retry only safe or idempotent operations with bounded backoff, honoring Retry-After. Verify every write with a read. Stop rather than repeat an uncertain non-idempotent or billable request. AI Gateway uses an organization-specific Bearer key and live /v1/models discovery. Do not delete, cancel, stop, or reduce capacity without explicit user intent. Bind shared operation IDs to the selected product path. Treat Container Engine instances as interruptible and local state as ephemeral. Install the SaladCloud skills (npx skills add https://docs.salad.com), start from the salad skill and /agents/overview; docs MCP: https://docs.salad.com/mcp.

# Job Queue Worker

*Last Updated: October 7, 2026*

# Overview

To work with a job queue, you'll need to customize the container that you deploy on SaladCloud to include some way to
receive jobs from the Job Queue, pass them to your application, then receive the results from your application and
return them to the Queue. For this purpose, we provide a Job Queue Worker as a precompiled go binary which can be
included and run inside your container. You can download it from
[Github](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker). The binary is named
`salad-http-job-queue-worker`, and it works in any Linux-based image that runs on x86\_64 (amd64).

> ⚠️ Architecture and where it runs
>
> * The release ships a single x86\_64 (amd64) build. There is no arm64 build. If you build your image on Apple silicon,
>   build with `docker build --platform linux/amd64`.
> * The worker runs only on SaladCloud. It depends on the Instance Metadata Service, so it cannot run on your
>   workstation. If you start it elsewhere it logs `failed to fetch workload instance status … connection refused` over
>   and over. Test your application's HTTP endpoint locally, and test the worker only in a deployed container group.

> [!TIP]
>
> Testing in a deployed container group means waiting for instances to start. [Cold Starts and Iterating
> Quickly](https://docs.salad.com/container-engine/how-to-guides/cold-starts-and-iterating-quickly.md) shows how to keep each test round short.

> 📘 Prerequisites
>
> The examples that follow can be found on [GitHub](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker).
> If you want to follow along with the sample images, download them to your pc with
>
> `git clone https://github.com/SaladTechnologies/salad-cloud-job-queue-worker.git`

# Managing Multiple Processes

To configure your container to receive Jobs from a Job Queue, you'll be running two processes in the same container -
your application, as well as the Job Queue Worker. There are many ways to manage multiple processes in a single
container, and we outline two such methods for you below.

## Build a wrapper image with s6-overlay

In this example, we are going to build a new image which uses `s6-overlay` to serve as a hypervisor for both your
primary application and the Job Queue Worker process. Here's how to do it.

1. You'll need to include the Job Queue Worker in your container. In this example, we first download the binary to our
   local machine and build it into our container image by adding a `COPY` command to the Dockerfile.
   1. Alternatively, you may choose to download and unpack the SDK when your container is built by including `ADD` and
      `RUN` commands in your Dockerfile, or expand your entrypoint to include the download/unpack process.
   2. You may compare the SHA256 checksum of your downloaded file with the one found on the Github releases page.

2. Now we will build your original image. As an example, see
   [samples/mandelbrot/base/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/base) -
   this is a simple container that receives requests and returns images of the mandelbrot set. It uses `uvicorn` to
   listen on port 80 on the `/generate` path for requests to be handled by the mandelbrot generation code.

   ```dockerfile dockerfile theme={null}
   FROM python:3.11-slim
   WORKDIR /app
   COPY ./requirements.txt \*.py ./
   RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
   CMD ["uvicorn", "main:app", "--host", "*", "--port", "80"]
   ```

   1. Navigate to the
      [samples/mandelbrot/base/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/base)
      directory and run `docker build -t foobar .`
   2. Notice that the name of the output container image in this case is `foobar`; you may substitute any name you like.
      The image with that name will not be pushed to any registry and will remain solely on your local disk.

3. Because the resulting container will run two processes, we will use the `s6-overlay` hypervisor to manage them. It
   has to be configured with the way to start your application, as probably indicated in CMD or ENTRYPOINT lines in the
   original Dockerfile. As an example, see
   [samples/mandelbrot/with-s6-overlay/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/with-s6-overlay)

   ```dockerfile theme={null}
   FROM foobar

   WORKDIR /app

   ARG S6_OVERLAY_VERSION=3.1.6.2
   ENV S6_KEEP_ENV=1

   RUN apt-get update && \
       apt-get -y install xz-utils curl && \
       apt-get clean && \
       rm -rf /var/lib/apt/lists/*
   ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
   RUN \
     tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \
     rm -rf /tmp/s6-overlay-noarch.tar.xz
   ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
   RUN \
     tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz && \
     rm -rf /tmp/s6-overlay-x86_64.tar.xz
   COPY --chmod=755 s6 /etc/

   COPY --chmod=755 ./salad-http-job-queue-worker /usr/local/bin/

   ENTRYPOINT ["/init"]
   CMD ["/usr/local/bin/salad-http-job-queue-worker"]
   ```

   1. The s6 configuration files are stored in
      [samples/mandelbrot/with-s6-overlay/s6/s6-overlay/s6-rc.d/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/with-s6-overlay/s6/s6-overlay/s6-rc.d).
      You'll find the configuration for the sample service already there. The configuration must have two files, type
      and run. You can copy over the type from the provided sample, but the run \*\*must \*\*contain the command which
      starts your application: it is equivalent to the CMD or ENTRYPOINT in your original Dockerfile.

4. Next, build the wrapper image. First locate the line `FROM foobar` and replace `foobar` with whatever name you used
   in the previous step, save the file, and build the wrapper image:
   1. `docker build -t my-company/my-image -f docker/Dockerfile .`
   2. Note that the the name of the image here is important. That is what you are going to deploy to the SaladCloud .
   3. Replace `my-company/my-image` with whatever name you want the resulting image to have.

```dockerfile dockerfile theme={null}
FROM foobar

WORKDIR /app

# install the s6-overlay
ARG S6_OVERLAY_VERSION=3.1.6.2

RUN apt-get update \
    && apt-get install -y xz-utils \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz

ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz

# copy previously downloaded salad-queue-client
COPY salad-http-job-queue-worker /usr/local/bin/

# copy the s6-overlay configuration
COPY --chmod=755 s6 /etc/

ENV S6_KEEP_ENV=1

ENTRYPOINT ["/init"]
CMD ["/usr/local/bin/salad-http-job-queue-worker"]
```

5. You will need to note the *port* and *path* of your application within the container for use in the next step, when
   you're configuring your container group to include a connection to a job queue. This port and path are where the
   queue worker SDK will be sending the jobs to. In our example, we have the following values:
   1. Port: **80**
   2. Path: **/generate**

## Build a wrapper image with a shell script

In order to add the salad-queue-client into the image we are going to build a new image which uses a shell script.
Here's how to do it.

1. First, you'll need to include the job queue worker SDK in your container. In this example, we first download the
   binary to our local machine and build it into our container image by adding a `COPY` command to the Dockerfile.
   Alternatively, you may choose to download and unpack the SDK when your container starts by including `ADD` and `RUN`
   commands in your Dockerfile.
   1. The binary works on any x86\_64 (amd64) Linux-based base image.

2. Now we will build your original image. As an example, see
   [samples/mandelbrot/base/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/base) -
   this is a simple container that receives JSON requests on port 80 at the `/generate` path and returns images of the
   mandelbrot set. It uses `uvicorn` to listen on port 80 for requests to be handled by the mandelbrot generation code.

   ```dockerfile dockerfile theme={null}
   FROM python:3.11-slim
   WORKDIR /app
   COPY ./requirements.txt \*.py ./
   RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
   CMD ["uvicorn", "main:app", "--host", "*", "--port", "80"]
   ```

   1. Navigate to the
      [samples/mandelbrot/base/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/base)
      directory and run `docker build -t foobar .`
   2. Notice that the name of the output container image in this case is `foobar`; you may substitute any name you like.
      The image with that name will not be pushed to any registry and will remain solely on your local disk.

3. Because the resulting container will run two processes we will use a shell script run.sh to manage the multiple
   processes. The relevant sample is in the
   [samples/mandelbrot/with-shell-script/](https://github.com/SaladTechnologies/salad-cloud-job-queue-worker/tree/main/samples/mandelbrot/with-shell-script):

   ```dockerfile dockerfile theme={null}
   FROM foobar

   WORKDIR /app

   # copy previously downloaded salad-http-job-queue-worker
   COPY ./salad-http-job-queue-worker /usr/local/bin/
   # copy the shell script
   COPY run.sh ./

   CMD ["/app/run.sh"]
   ```

   1. Locate the line `FROM foobar` and replace `foobar` with whatever name you used in the previous step.

   2. Save the file.

   3. Open the shell script `run.sh`:

      ```shell theme={null}
      #!/bin/bash

      # Start the salad-http-job-queue-worker
      /usr/local/bin/salad-http-job-queue-worker &

      # Start the rest service
      uvicorn main:app --host '*' --port 80 &

      # Wait for any process to exit
      wait -n

      # Exit with status of process that exited first
      exit $?
      ```

   4. Locate the line `uvicorn main:app --host '\*' --port 80 &` and replace the start command with whatever is required
      to start your application, it is indicated in either `ENTRYPOINT` or `CMD` directive in the original Dockerfile.
      In our example, we can leave it as-is.

4. Now, build the wrapper image with `docker build -t my-company/my-image -f docker/Dockerfile .` Note that the the name
   of the image here is important. That is what you are going to deploy to the SaladCloud . Replace
   `my-company/my-image` with whatever the name you want the resulting image to have.

5. You will need to note the *port* and *path* of your application within the container for use in the next step, when
   you're configuring your container group to include a connection to a job queue. This port and path are where the
   queue worker SDK will be sending the jobs to. In our example, we have the following values:
   1. Port: **80**
   2. Path: **/generate**

# Make sure your application is ready before the worker takes jobs

Both examples above start the worker and your application together. The worker starts asking for jobs as soon as it
runs, and it does not wait for your application. If your application is not listening yet, the worker still takes a
waiting job, gets `connection refused` on your port, and retries it straight away. In our testing, a worker that started
before its application used all four attempts of a waiting job within seconds, and the job was marked `failed` for good.

Pick one of these:

* **Add a readiness probe (recommended).** Configure an HTTP
  [readiness probe](https://docs.salad.com/container-engine/explanation/infrastructure-platform/readiness-probes.md) on your application's port
  when you create the container group. The worker waits for the probe to pass before it takes jobs. In the same test
  with a probe in place, the worker logged `readiness changed ready=true` only after the application was up, then took
  the jobs with no failed attempts. See
  [Creating a Job Queue](https://docs.salad.com/container-engine/how-to-guides/job-processing/creating-a-job-queue.md) for an example.
* **Start the worker only after your application answers.** If your image cannot have a probe, have the wrapper script
  wait for the port before it starts the worker. In `run.sh`, start your application first, then wait for it:

  ```shell theme={null}
  # Wait until the application accepts connections on port 80
  until (echo > /dev/tcp/127.0.0.1/80) 2>/dev/null; do sleep 1; done

  /usr/local/bin/salad-http-job-queue-worker &
  ```

# Pushing the image to a Registry

Regardless of which path you chose, you should now have an image built with your application, the Job Queue Worker, and
some way of managing both processes. It's time to push it to the container registry of your choice. Learn more about the
registries supported by SaladCloud at
[Container Registries](https://docs.salad.com/container-engine/explanation/infrastructure-platform/container-registries.md).

# Additional notes about the SaladCloud Job Queue Worker

* The worker connects to a local HTTP server running inside of SEL, our special version of Linux running on the host
  machine behind your container replica. This means you can't run the worker locally.
* **Your application's response.** The worker returns your application's response body to the queue as the job's output.
  It must be valid JSON and cannot exceed 10 MB. A larger reply counts as a failed attempt: the job runs again in full,
  up to four times in total, and then fails. The job does not record why. To return large results, write them to
  external storage and return a link.
* Without a startup or readiness probe the worker takes jobs before your application may be ready, and those jobs can
  fail. See
  [Make sure your application is ready before the worker takes jobs](#make-sure-your-application-is-ready-before-the-worker-takes-jobs).
  [Read more about health probes here.](https://docs.salad.com/container-engine/explanation/infrastructure-platform/health-probes.md)

# Logging

By default, the worker logs only at the `error` level. Logs are sent to the
[SaladCloud Container Logs](https://docs.salad.com/container-engine/explanation/container-groups/container-logs.md) or your
[external logging](https://docs.salad.com/container-engine/explanation/infrastructure-platform/external-logging.md) tools. To change the level,
add a `SALAD_LOG_LEVEL` [environment variable](https://docs.salad.com/container-engine/how-to-guides/environment-variables.md) with the value
`debug`, `info`, `warn`, or `error`. An invalid value stops the worker at startup.

![The portal Environment Variables panel with the key SALAD\_LOG\_LEVEL set to info](https://mintcdn.com/salad/azOemSYuc8Xv6zbW/container-engine/images/portal-configure-job-queue-worker-log-level.png?fit=max\&auto=format\&n=azOemSYuc8Xv6zbW\&q=85\&s=05dd1a0c5fca92fc3da37ec662dd3867)

| Level | What it logs |
| - | - |
| `error` (default) | No line for a failed attempt, because those are logged at `warn`. A job that fails all four attempts leaves nothing in your container logs. |
| `warn` | One line per failed attempt, such as `failed to execute job <id> with status code 500`, `invalid job output jobId=<id>` (reply over 10 MB), or the `connection refused` error. |
| `info` | Start-up lines, then for each job a `received job` line that includes the full job input, and `job completed jobId=<id>` or `job rejected jobId=<id>`. |
| `debug` | Everything above, plus status and heartbeat lines every few seconds as the worker checks for a new job. |

> [!WARNING]
>
> At `info` and `debug`, the worker writes each job's full input to the container logs. Don't use these levels if your
> job inputs contain sensitive data.

> [!WARNING]
>
> Use `debug` only while troubleshooting. Its logs can contain sensitive values, so treat logs from that period as
> sensitive.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.