Developers

Environment variables

Every container option and its exit codes.

Updated:

Variables

VariableDefaultWhat it does
PIAP_TOKEN / PIAP_TOKEN_FILE(required)Server token with the computers scope, or path to a file that holds it.
PIAP_NETWORKprodprod (piap.io) or lab (lab network).
PIAP_NAMEhost nameName in My computers.
PIAP_DATA_DIR/dataData folder (volume).
PIAP_MODELS(empty)Allowed catalog ids, comma separated; downloaded on start. Empty = any model that fits.
PIAP_MAX_MEMORY_PERCENT70Memory (or GPU memory) a model may use, 10 to 90.
PIAP_DISK_GB40Space for models.
PIAP_MAX_CONCURRENT1Requests at a time.
PIAP_DAILY_TOKENS0Daily 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_YIELDoffon: yields to other programs on the server (memory above 85 %, CPU above 75 %).
PIAP_OWN_USEonYour own requests can go to this computer without credits.
PIAP_NETWORKS(global)Private networks in priority order (ids), and global.
PIAP_LOCATION / PIAP_REGIONcountry / (empty)Precision on the map (city, country, off) and declared region.
PIAP_GRACE_SECONDS60Shutdown grace to finish in-flight requests.
PIAP_REMOVE_ON_EXITfalseOn shutdown, removes itself from My computers (pods without a volume).
PIAP_LISTEN:9090Address for health, status and metrics.
PIAP_LOG_FORMAT / PIAP_LOG_LEVELjson / infoLogs 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

  1. On SIGTERM, the computer pauses: it takes no new requests.
  2. It waits up to PIAP_GRACE_SECONDS for in-flight requests to finish.
  3. 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.
  4. 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

CodeMeaning
0Normal shutdown.
2Invalid configuration: check the logs, they name the variable.
3Token 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.