Start command and port
Copy page
Grayspar starts each service with a command it works out from your code, and tells the service which port to listen on. Most apps need nothing from you. This page covers the cases that do.
How Grayspar starts a service
Section titled “How Grayspar starts a service”A service with a Dockerfile starts with the Dockerfile’s CMD. A Dockerfile with no CMD fails its build with this message:
This image has no start command. Add a CMD line to the Dockerfile.Any other service builds with Railpack, which picks the start command for the framework it recognises. For example, Railpack starts a Next.js app with next start, and a FastAPI app with uvicorn.
Set your own start command
Section titled “Set your own start command”When Railpack can’t tell how to start your app, or starts it the wrong way, add a file called Procfile to the service’s folder. Its web line holds the command:
web: uvicorn server:app --host 0.0.0.0 --port $PORTA Streamlit app is a common case, because Railpack sees a Python project and can’t tell that app.py is a Streamlit app:
web: streamlit run app.py --server.port $PORT --server.address 0.0.0.0If nothing in a folder says how to start it, the deploy stops before building and names the folder:
Nothing in api says how to start it.Listen on the right port
Section titled “Listen on the right port”A service has to listen on the port in its PORT variable, on the address 0.0.0.0. Grayspar sets PORT to 8080, or to the port a Dockerfile’s EXPOSE line names. An app that listens on localhost alone can’t be reached.
If your app always listens on one port, set PORT to that port:
grayspar env set PORT=3000A service with a path that doesn’t answer on its port fails to deploy, and the version already running stays live. The deployment’s log says what went wrong:
This service isn't answering on port 8080. If it uses another port, set PORT to that port. If it takes no requests, run grayspar service set worker --no-path and deploy again.A background worker that takes no requests needs no port. Give it no path, as Services and paths describes.