Background processes
Programs that an account keeps running all the time, such as a queue worker or a Node.js server.
What they are for
A website's PHP runs only while a visitor's request is being answered, and a cron job runs at set times and ends. Some programs fit neither: they have to be running all the time.
- A queue worker, such as
php artisan queue:work, which sends mail and does other slow work outside of requests. - A Node.js server that renders pages for the site (Inertia SSR, for example).
- A WebSocket or other long-lived server that the site's own code talks to.
A background process is one such command. The server starts it, keeps it running, starts it again when it exits and starts it after a reboot.
Allowing them
Processes are part of the plan. Background processes on the plan form is the number of processes each account may have; it is 0 on a new plan, which switches the feature off.
- With a limit above 0 the customer gets a Processes page, after Cron jobs.
- An administrator manages any account's processes under Hosting → Processes. A process that an administrator creates is an ordinary process of that account and counts toward its limit.
- Lowering the limit never stops or deletes a process. An account over its limit keeps what runs; it cannot add a process or switch one back on until it is under the limit again.
Creating one
| Field | Meaning |
|---|---|
| Name | Lowercase letters, digits and dashes, up to 32 characters, unique in the account. alxpanel-process uses this name. |
| Site | A process belongs to one of the account's sites and runs in that site's folder. An account without an active site cannot have one. |
| Folder inside the site | Optional. The command runs in this folder, for example current when deploys switch a current link to the newest release. |
| Command | One shell command line, with the same rules as a cron job's command. |
| Needs a port | The panel gives the process a port. See Ports. |
The On switch stops and starts a process without deleting it.
How a process runs
- As the account's own Linux user, with the same restrictions as the account's cron jobs. It can read and write the account's files and nothing of another account.
- Inside the account's CPU and memory limits. There is no limit per process: the plan's limits cover the account's sites, cron jobs and processes together.
- With
HOMEset to the account's home,NODE_ENV=production, andPORTwhen the process has a port. - Node.js 22 and npm are installed with alxpanel. There is one Node.js version for every account.
When the command exits for any reason, the server starts it again: after 2 seconds the first time, then after longer waits, up to 60 seconds between attempts. It never gives up, so a command that fails at once stays in Restarting until it is fixed or switched off.
Stopping or restarting a process stops every program the command started. One that has not ended after 15 seconds is killed.
What the Process column says
| Shown | Meaning |
|---|---|
| Running since 14:05 | The command is running. |
| Restarting — exit 1, 7 restarts | The command exited and the server is waiting to start it again. The exit code is the command's own; View log shows what it printed. Exit code 200 means that the folder does not exist. |
| Stopped | Switched off, or the account is suspended. |
| Port … is in use | Another program on the server is listening on this process's port, so the process cannot start. It starts by itself once that program is gone. |
| status unavailable | The panel could not ask the server just now. |
A command that fails right after it starts shows Running for a moment between two Restarting reads.
Ports
With Needs a port on, the panel assigns the lowest free port between 20000 and 29999. The port is unique on the server and is never typed in. The process gets it in the PORT environment variable and should listen on 127.0.0.1.
The port is private to the account:
- The account's own sites, cron jobs, SSH sessions and other processes can connect to it.
- Every other account is refused, on every address of the server.
- It is closed from outside the server. The panel does not publish it under a domain: a process serves the account's own code, not visitors directly.
The port is freed when the process is deleted or Needs a port is switched off, and may then go to another process.
Logs
View log shows the newest 1000 lines of what the process wrote to standard output and standard error. A process that writes more than 1000 lines in 30 seconds loses the rest for that period.
Restarting after a deploy
A worker keeps the code it started with, so a deploy has to restart it. Restart on the page does that; from a deploy script, the account's user runs:
alxpanel-process restart queue
See alxpanel-process.
What else stops or restarts a process
| Event | Effect |
|---|---|
| The account is suspended | Every process is stopped. Unsuspending starts those that were switched on. |
| The site is deleted | Its processes are deleted with it. |
| The account is deleted | Its processes are deleted. |
| The server reboots | Every switched-on process starts again. |
| alxpanel is updated | Processes keep running. A release that changes how processes are run restarts each one once. |
Example: Inertia SSR
- Make the server in
ssr.jslisten on the given port:createServer(page => …, { port: process.env.PORT }). - Create a process with the command
node bootstrap/ssr/ssr.jsand Needs a port on. - The Port column shows the number. Put
INERTIA_SSR_URL=http://127.0.0.1:<port>in the site's.env.