Systemd
Run the p2pstream release binary as a Linux systemd service, or operate an agent installed by the generated Linux installer.
Use This When
Use systemd when you install the release binary directly on a host, or when managing an agent installed from the Agent Setup modal opened from Agents.
Prerequisites
- Linux with systemd.
/usr/local/bin/p2pstreaminstalled.- A persistent server data directory such as
/var/lib/p2pstream, or an agent env file generated by the installer.
Steps
Create server directories:
bashsudo install -d -m 0700 /var/lib/p2pstream sudo install -d -m 0755 /etc/p2pstreamCreate
/etc/p2pstream/server.env:iniCONFIG_DIR=/var/lib/p2pstream MANAGEMENT_PORT=8081 MANAGEMENT_PUBLIC_URL=https://proxy.example.com:8081 ENV=productionCreate
/etc/systemd/system/p2pstream.service:ini[Unit] Description=p2pstream reverse proxy After=network-online.target Wants=network-online.target [Service] EnvironmentFile=/etc/p2pstream/server.env ExecStart=/usr/local/bin/p2pstream server Restart=always RestartSec=5s User=root [Install] WantedBy=multi-user.targetEnable the server:
bashsudo systemctl daemon-reload sudo systemctl enable --now p2pstream sudo systemctl status p2pstream
Root is required when binding privileged ports such as 80 or 443. If you only use high ports, run as a dedicated user and adjust ownership of /var/lib/p2pstream.
Agent Service
The generated Linux installer writes:
/etc/p2pstream/agent.env
/etc/systemd/system/p2pstream-agent.serviceThe service runs:
[Service]
EnvironmentFile=/etc/p2pstream/agent.env
ExecStart=/usr/local/bin/p2pstream agent
Restart=always
RestartSec=5s
User=p2pstream
Group=p2pstream
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/p2pstream-agentOperate it with:
sudo systemctl status p2pstream-agent
sudo systemctl restart p2pstream-agent
sudo journalctl -u p2pstream-agent -fAfter rotating an agent token, run the generated Linux reinstall command on the existing agent host. The installer rewrites /etc/p2pstream/agent.env, refreshes installer-managed management CA material, and restarts p2pstream-agent so the new token and TLS settings are loaded. A locally configured AGENT_ALLOW_TARGETS or AGENT_ALLOW_ANY_TARGET policy is preserved when the reinstall command does not provide a replacement. If the existing environment file cannot be read or contains unsupported or multiline assignment syntax, the reinstall stops instead of risking a policy change; provide a replacement explicitly or add AGENT_CLEAR_ALLOW_TARGETS=true to discard the old policy and revert to loopback-only.
The installer also creates /var/lib/p2pstream-agent/management-ca.pem as the service-owned durable trust bundle. Management certificate rotation updates this file atomically. If forced activation strands an otherwise current agent, use the trust-repair command shown under Settings → Management TLS. If the agent version is incompatible or its configuration is damaged, rerun the full generated install command instead.
Uninstall Agent
Use this only for agents installed with the generated Linux systemd installer. Docker Compose agents should be removed with your Compose workflow instead.
The full-purge uninstall removes the agent service, service drop-ins, /etc/p2pstream, /var/lib/p2pstream-agent, /usr/local/bin/p2pstream, and the p2pstream service user and group. Do not run it on a host where those paths or that user are shared with a p2pstream server or another install you want to keep.
Generated command:
curl -fsSL https://raw.githubusercontent.com/Kirari04/p2pstream/main/scripts/uninstall-agent.sh | sudo env P2PSTREAM_UNINSTALL_CONFIRM=full-purge bashPreview without changing the host:
curl -fsSL https://raw.githubusercontent.com/Kirari04/p2pstream/main/scripts/uninstall-agent.sh | env P2PSTREAM_UNINSTALL_DRY_RUN=true P2PSTREAM_UNINSTALL_CONFIRM=full-purge bashUninstalling the host service does not remove the management record. After the remote host is removed, open the agent row's More menu under Agents and delete or disable the management record.
Verification
Check server or agent status:
sudo systemctl status p2pstream
sudo journalctl -u p2pstream -f
sudo systemctl status p2pstream-agentTroubleshooting
| Symptom | Check |
|---|---|
| Server cannot bind low ports | Run as root or use capabilities/high ports. |
| Agent fails after token rotation | Run the generated Linux reinstall command on the existing agent host. |
| Uninstall refuses to run | Set P2PSTREAM_UNINSTALL_CONFIRM=full-purge; unsafe paths are intentionally rejected. |