Developers
Environment variables
Every container option and its exit codes.
Variables
| Variable | Default | What it does |
|---|---|---|
PIAP_TOKEN / PIAP_TOKEN_FILE | (required) | Server token with the computers scope, or path to a file that holds it. |
PIAP_NETWORK | prod | prod (piap.io) or lab (lab network). |
PIAP_NAME | host name | Name in My computers. |
PIAP_DATA_DIR | /data | Data folder (volume). |
PIAP_MODELS | (empty) | Allowed catalog ids, comma separated; downloaded on start. Empty = any model that fits. |
PIAP_MAX_MEMORY_PERCENT | 70 | Memory (or GPU memory) a model may use, 10 to 90. |
PIAP_DISK_GB | 40 | Space for models. |
PIAP_MAX_CONCURRENT | 1 | Requests at a time. |
PIAP_DAILY_TOKENS | 0 | Daily cap on network tokens; 0 = no cap. |
PIAP_HOURS / PIAP_DAYS | (always) | Window HH:MM-HH:MM and days 1-5 or 0,6 (0 = Sunday), in the TZ time zone (UTC by default). |
PIAP_YIELD | off | on: yields to other programs on the server (memory above 85 %, CPU above 75 %). |
PIAP_OWN_USE | on | Your own requests can go to this computer without credits. |
PIAP_NETWORKS | (global) | Private networks in priority order (ids), and global. |
PIAP_LOCATION / PIAP_REGION | country / (empty) | Precision on the map (city, country, off) and declared region. |
PIAP_GRACE_SECONDS | 60 | Shutdown grace to finish in-flight requests. |
PIAP_REMOVE_ON_EXIT | false | On shutdown, removes itself from My computers (pods without a volume). |
PIAP_LISTEN | :9090 | Address for health, status and metrics. |
PIAP_LOG_FORMAT / PIAP_LOG_LEVEL | json / info | Logs on standard output, with no personal data. |
Hours in PIAP_HOURS are read in the TZ time zone. If you do not set it, they are UTC.
Graceful shutdown
- On SIGTERM, the computer pauses: it takes no new requests.
- It waits up to
PIAP_GRACE_SECONDSfor in-flight requests to finish. - Those still running go back to the network: another computer handles them, the hold is returned to the requester and your reputation is not penalized.
- It stops the engine and exits with code 0.
That is why the stop timeout (--stop-timeout, stop_grace_period or terminationGracePeriodSeconds) should be the grace plus about 30 seconds.
Exit codes
| Code | Meaning |
|---|---|
0 | Normal shutdown. |
2 | Invalid configuration: check the logs, they name the variable. |
3 | Token rejected: invalid, expired, revoked, missing the computers scope, or the computer was removed in My computers. |
With code 3 the container does not recover by restarting: fix the token or create a new one. If you removed the computer in My computers on purpose, stop the container or delete its volume so it joins as a new computer.