For the complete documentation index, see llms.txt. This page is also available as Markdown.

Startup Scripts

Run a Bash script as root on a Dedicated Deployment before inference starts.

A startup script installs packages or downloads data on a Dedicated Deployment before inference starts. Use one when your models or Workflows need a Python package, a system tool, or a data file that the inference container does not include.

Startup scripts are off by default. Contact sales to turn them on for your workspace.

About

The script is Bash. It runs as root on every container start, including new replicas and restarts. Inference then runs as a non-root user.

Your script must finish within 10 minutes. An error or a timeout stops inference from starting, and the container tries again. Start the script with set -e so it stops on a failed command, and write it so that running it again is safe.

Nothing is prepared for you. Install any tool you need, such as pip. Files under /userdata can be lost when the container is replaced or the deployment is paused, so download them again on each start. Environment variables that your script exports are not passed to inference.

INFERENCE_UID and INFERENCE_GID hold the numeric user and group IDs that inference runs as. Use them to give inference access to the files your script creates.

#!/bin/bash
set -e
apt-get update
apt-get install -y --no-install-recommends curl jq python3-pip
python3 -m pip install 'humanize==4.12.3'
mkdir -p /userdata/custom-data
curl --fail --location 'https://YOUR_HOST/data.json' --output /userdata/custom-data/data.json
chown -R "$INFERENCE_UID:$INFERENCE_GID" /userdata/custom-data

A script can be 64 KiB at most and cannot contain NUL characters.

Web App

Enter the script in the "Startup Script (Bash)" field. The field is in the "Create a Dedicated Deployment" dialog and in the settings of an existing deployment. Select "Clear Script" to remove it.

Saving a script does not restart running containers. The change applies the next time a container starts. To apply it right away, pause the deployment and resume it.

To read the output of your script, select "View Logs" on the deployment, then select "Refresh" for new entries. The dialog shows up to 300 entries from the last hour across all replicas, and entries can take a short time to appear. Anything your script prints appears there, so do not print credentials.

Failures

A deployment pauses after every replica fails its startup script 5 times in a row. A success resets the count for that replica. The status then reads "Paused: Startup Script Failures". Fix or clear the script, then select "Resume". Incoming requests do not resume the deployment.

The person who created the deployment and the workspace owners get one email when the script starts failing. Roboflow sends no further email for the same failure until the deployment recovers or you change the script.

HTTP API

Dedicated Deployment endpoints are hosted at https://roboflow.cloud. See Dedicated Deployments for the rest of them.

Create a Deployment accepts an optional startup_script string in its body. To change the script on a deployment that already exists, post to /update_startup_script.

POST /update_startup_script

Name
Type
Description
Required

api_key

string

Workspace API key.

deployment_name

string

Deployment to update.

startup_script

string

Script contents. Send an empty string to remove the script.

Last updated

Was this helpful?