Skip to main content

Overview

PROPPR services run as systemd units for automatic startup, restart on failure, and centralized management.

Service Configuration

Bot Services

Create systemd service files in /etc/systemd/system/ for each bot:
[Unit]
Description=PROPPR Team Bot
After=network.target mongod.service
Wants=mongod.service

[Service]
Type=simple
User=root
WorkingDirectory=/opt/proppr/PropprTeamBot
Environment="PYTHONPATH=/opt"
Environment="PYTHONUNBUFFERED=1"
ExecStart=/usr/bin/python3.11 -m PROPPR.PropprTeamBot.core.bot.team_bot
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=proppr-team

[Install]
WantedBy=multi-user.target

Data Services

[Unit]
Description=PROPPR WebSocket Updater
After=network.target mongod.service
Wants=mongod.service

[Service]
Type=simple
User=root
WorkingDirectory=/opt/proppr/WebsocketUpdater
Environment="PYTHONPATH=/opt"
Environment="PYTHONUNBUFFERED=1"
ExecStart=/usr/bin/python3.11 -m PROPPR.WebsocketUpdater.core.websocket_updater
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=proppr-websocket

[Install]
WantedBy=multi-user.target

Grading Services

[Unit]
Description=PROPPR Team Grading Scheduler
After=network.target mongod.service
Wants=mongod.service

[Service]
Type=simple
User=root
WorkingDirectory=/opt/proppr
Environment="PYTHONPATH=/opt"
Environment="PYTHONUNBUFFERED=1"
ExecStart=/usr/bin/python3.11 -c "from PROPPR.SharedServices.grading.scheduler.unified_scheduler import UnifiedGradingScheduler; from PROPPR.config import get_mongo_connection_string, get_mongo_database, get_footystats_api_key; scheduler = UnifiedGradingScheduler(mongo_connection_string=get_mongo_connection_string(), database_name=get_mongo_database(), api_token=get_footystats_api_key(), credentials_path='credentials.json', spreadsheet_name='PROPPR Team Bot', bot_type='team'); scheduler.start()"
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=proppr-team-grader

[Install]
WantedBy=multi-user.target

Enable and Start Services

1

Reload systemd Configuration

After creating service files, reload systemd:
sudo systemctl daemon-reload
2

Enable Services for Auto-Start

Enable services to start automatically on boot:
# Enable all bot services
sudo systemctl enable team-bot player-bot ev-bot arb-bot horse-bot overtime-bot

# Enable data services
sudo systemctl enable websocket-updater unified-poller

# Enable grading services
sudo systemctl enable team-grader player-grader
3

Start Services

Start all services:
# Start all services at once
sudo systemctl start team-bot player-bot ev-bot arb-bot horse-bot overtime-bot \
                      websocket-updater unified-poller team-grader player-grader

Service Management Commands

Check Service Status

# Check status of all PROPPR services
systemctl status 'proppr-*'

# Check specific service
systemctl status team-bot

# List all PROPPR services
systemctl list-units '*-bot' '*-updater' '*-poller' '*-grader'

Start/Stop/Restart Services

# Restart a specific service
sudo systemctl restart team-bot

# Stop a service
sudo systemctl stop player-bot

# Start a service
sudo systemctl start ev-bot

# Restart all bot services
sudo systemctl restart team-bot player-bot ev-bot arb-bot horse-bot overtime-bot

View Service Logs

# Follow logs for a service
journalctl -u team-bot -f

# View last 100 lines
journalctl -u player-bot -n 100

# View logs since today
journalctl -u ev-bot --since today

# View logs with timestamps
journalctl -u arb-bot -o short-iso

Deployment Workflow

The push_and_restart.sh script automates deployment from local to production:
scripts/deploy/push_and_restart.sh
#!/bin/bash
# Deploy changes to production server

SERVER="46.224.85.158"
PROPPR_LOCAL="/path/to/local/PROPPR"
PROPPR_REMOTE="/opt/proppr"

# Sync files to server
rsync -avz --exclude '__pycache__' --exclude '*.pyc' --exclude 'tests' \
    "$PROPPR_LOCAL/PropprTeamBot/" root@$SERVER:"$PROPPR_REMOTE/PropprTeamBot/"

# Restart service
ssh root@$SERVER "systemctl restart team-bot"

Deploy Specific Module

./scripts/deploy/push_and_restart.sh
# Select option 1

Troubleshooting

Check the service logs:
journalctl -u team-bot -n 50
Common issues:
  • Missing Python dependencies
  • Incorrect PYTHONPATH
  • MongoDB not running
  • Missing credentials in .env
Check for Python exceptions in logs:
journalctl -u team-bot -f | grep -i error
Increase RestartSec in service file to avoid rapid restart loops.
Verify MongoDB is running:
systemctl status mongod
Check MongoDB connection string in /opt/proppr/.env.
Ensure service user has read access:
sudo chown -R root:root /opt/proppr
sudo chmod 755 /opt/proppr
sudo chmod 600 /opt/proppr/.env

Next Steps

Monitor Services

Set up comprehensive monitoring and health checks

Build docs developers (and LLMs) love