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 Agents setup dialog.
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=trueOperate it with:
sudo systemctl status p2pstream-agent
sudo systemctl restart p2pstream-agent
sudo journalctl -u p2pstream-agent -fAfter rotating an agent token, update /etc/p2pstream/agent.env and restart the agent.
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, /etc/p2pstream, /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, delete or disable the agent from Agents.
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 | Update /etc/p2pstream/agent.env and restart. |
| Uninstall refuses to run | Set P2PSTREAM_UNINSTALL_CONFIRM=full-purge; unsafe paths are intentionally rejected. |