Setting Up Playit as a Systemd Service for 24/7 Operation
Overview
This guide explains how to install Playit and configure it to run as a systemd service so that it starts automatically on boot and runs continuously. It also includes troubleshooting steps for common errors.
Step 1: Install Playit
Run the following commands to install Playit on your system:
curl -SsL https://playit-cloud.github.io/ppa/key.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/playit.gpg >/dev/null
echo "deb [signed-by=/etc/apt/trusted.gpg.d/playit.gpg] https://playit-cloud.github.io/ppa/data ./" | sudo tee /etc/apt/sources.list.d/playit-cloud.list
sudo apt update
sudo apt install playit
Once installed, verify the installation by running:
which playit
This should return the installation path (e.g., /usr/local/bin/playit).
Step 2: Create a Systemd Service File
Open a terminal and create a new systemd service file:
sudo nano /etc/systemd/system/playit.service
Add the following content to the file:
[Unit]
Description=Playit Tunnel
After=network.target
[Service]
ExecStart=/usr/local/bin/playit
Restart=always
User=root
WorkingDirectory=/root
StandardOutput=journal
StandardError=journal
SyslogIdentifier=playit
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
Note: Ensure ExecStart points to the correct location of playit (use which playit to verify).
Save and exit (CTRL+X, then Y, then Enter).
Step 3: Enable and Start the Service
Run the following commands to reload systemd and start Playit:
sudo systemctl daemon-reload
sudo systemctl enable playit
sudo systemctl start playit
To verify if the service is running, check its status:
sudo systemctl status playit
You should see “active (running)” in the output.
Step 4: Verify Automatic Startup
To ensure Playit starts on boot, reboot the system:
sudo reboot
After rebooting, check the service status again:
sudo systemctl status playit
If Playit is running, the setup is complete.
Troubleshooting Common Issues
Error: status=217/USER
Cause: The systemd service may not have the correct user or working directory.
Solution: Modify the service file and ensure:
User=root is set.
WorkingDirectory=/root is correctly defined.
Run:
sudo systemctl daemon-reload
sudo systemctl restart playit
Error: status=203/EXEC
Cause: The ExecStart path is incorrect or the file is not executable.
Solution:
Verify the correct path:
which playit
Ensure the file is executable:
sudo chmod +x /usr/local/bin/playit
Update playit.service with the correct path in ExecStart.
Reload and restart the service:
sudo systemctl daemon-reload
sudo systemctl restart playit
Playit Fails to Start on Boot
Check logs for errors:
journalctl -u playit --no-pager | tail -n 50
If there are network-related issues, ensure that After=network.target is set in the service file.
If you experience any issues connecting to the IP provided by playit, check your agent settings and try disabling IPV6.