# SmartBotic Systemd Services This directory contains systemd user service files for managing SmartBotic processes. ## Installation 1. Link or copy the service files to your user systemd directory: ```bash mkdir -p ~/.config/systemd/user ln -sf /data/smartbotic/systemd/user/*.service ~/.config/systemd/user/ ln -sf /data/smartbotic/systemd/user/*.target ~/.config/systemd/user/ ``` 2. Reload systemd to pick up the new services: ```bash systemctl --user daemon-reload ``` ## Usage ### Start all services ```bash systemctl --user start smartbotic.target ``` ### Start individual services ```bash systemctl --user start smartbotic-database systemctl --user start smartbotic-webserver systemctl --user start smartbotic-runner ``` ### Stop all services ```bash systemctl --user stop smartbotic.target ``` ### Stop individual services ```bash systemctl --user stop smartbotic-runner systemctl --user stop smartbotic-webserver systemctl --user stop smartbotic-database ``` ### Restart services ```bash systemctl --user restart smartbotic-webserver systemctl --user restart smartbotic-runner ``` ### Check status ```bash systemctl --user status smartbotic-database systemctl --user status smartbotic-webserver systemctl --user status smartbotic-runner ``` ### View logs ```bash # Follow logs for a specific service journalctl --user -u smartbotic-webserver -f # View last 100 lines journalctl --user -u smartbotic-runner -n 100 # View all SmartBotic logs journalctl --user -u 'smartbotic-*' -f ``` ### Enable auto-start on login ```bash systemctl --user enable smartbotic.target ``` ### Disable auto-start ```bash systemctl --user disable smartbotic.target ``` ## Service Dependencies ``` smartbotic-database ↓ smartbotic-webserver ↓ smartbotic-runner ``` The services have proper dependency ordering: - `smartbotic-database` must start first - `smartbotic-webserver` depends on database and starts after it - `smartbotic-runner` depends on webserver and starts after it ## Environment Variables You can override environment variables in the service files or create an override: ```bash systemctl --user edit smartbotic-runner ``` Add your overrides: ```ini [Service] Environment=LOG_LEVEL=debug Environment=RUNNER_ID=my-runner ``` ## Troubleshooting If services fail to start, check the logs: ```bash journalctl --user -u smartbotic-database -e journalctl --user -u smartbotic-webserver -e journalctl --user -u smartbotic-runner -e ``` Common issues: - Port already in use: Check if another instance is running - Database connection failed: Ensure database service is running - Runner registration failed: Ensure webserver is accessible