From 736a81949352e0ac138d3a1b6074a172d4330fc9 Mon Sep 17 00:00:00 2001 From: Spencer Date: Sun, 18 Jan 2026 18:09:10 -0600 Subject: [PATCH] feat: Rename pockettts service to vox and improve numba caching Renamed the systemd service from "pockettts" to "vox" for better branding and clarity. Updated the script to reflect the new service name. Addressed numba caching issues when running as a systemd service: - Created to explicitly set to a project-local directory (). - Modified to import early in the execution flow. - Updated the systemd service file to grant write permissions to the directory. - Added to to prevent caching files from being committed. --- .gitignore | 1 + bot.py | 1 + numba_config.py | 19 +++++++++++++++++++ setup_linux.sh | 32 ++++++++++++++++---------------- voices/preferences.json | 2 +- 5 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 numba_config.py mode change 100644 => 100755 setup_linux.sh diff --git a/.gitignore b/.gitignore index ebc9ccb..27d775d 100644 --- a/.gitignore +++ b/.gitignore @@ -121,6 +121,7 @@ ENV/ env.bak/ venv.bak/ /venv +.numba_cache/ # Gemini files GEMINI.md PROGRESS.md \ No newline at end of file diff --git a/bot.py b/bot.py index 07b5efa..22f6795 100644 --- a/bot.py +++ b/bot.py @@ -1,3 +1,4 @@ +import numba_config import asyncio import io from typing import Any diff --git a/numba_config.py b/numba_config.py new file mode 100644 index 0000000..9a38fe1 --- /dev/null +++ b/numba_config.py @@ -0,0 +1,19 @@ +import os +import sys + +# Set a writable cache directory for Numba +# This is crucial when running as a systemd service with restricted home directory access. +# The cache will be created in the bot's root directory. +CACHE_DIR = os.path.join(os.path.dirname(__file__), '.numba_cache') + +if not os.path.exists(CACHE_DIR): + try: + os.makedirs(CACHE_DIR) + print(f"Numba cache directory created at: {CACHE_DIR}") + except OSError as e: + print(f"Error creating Numba cache directory: {e}", file=sys.stderr) + +# Set the environment variable for Numba +os.environ['NUMBA_CACHE_DIR'] = CACHE_DIR + +print(f"Numba cache directory set to: {os.environ.get('NUMBA_CACHE_DIR')}") diff --git a/setup_linux.sh b/setup_linux.sh old mode 100644 new mode 100755 index e6b5aef..992529f --- a/setup_linux.sh +++ b/setup_linux.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Pocket TTS Discord Bot - Linux Setup Script +# Vox Discord Bot - Linux Setup Script # This script helps set up the bot and install it as a systemd service set -e @@ -12,7 +12,7 @@ YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${GREEN}========================================${NC}" -echo -e "${GREEN} Pocket TTS Discord Bot - Linux Setup${NC}" +echo -e "${GREEN} Vox Discord Bot - Linux Setup${NC}" echo -e "${GREEN}========================================${NC}" echo @@ -138,11 +138,11 @@ read -p "Do you want to install the bot as a systemd service? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then # Create the service file with correct paths - SERVICE_FILE="/tmp/pockettts.service" + SERVICE_FILE="/tmp/vox.service" cat > "$SERVICE_FILE" << EOF [Unit] -Description=Pocket TTS Discord Bot +Description=Vox Discord Bot After=network-online.target Wants=network-online.target @@ -156,7 +156,7 @@ RestartSec=10 TimeoutStopSec=30 StandardOutput=journal StandardError=journal -SyslogIdentifier=pockettts +SyslogIdentifier=vox # Security hardening NoNewPrivileges=true @@ -170,26 +170,26 @@ WantedBy=multi-user.target EOF echo " Installing systemd service (requires sudo)..." - sudo cp "$SERVICE_FILE" /etc/systemd/system/pockettts.service + sudo cp "$SERVICE_FILE" /etc/systemd/system/vox.service sudo systemctl daemon-reload echo -e " ${GREEN}✓${NC} Service installed" read -p "Do you want to enable the service to start on boot? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then - sudo systemctl enable pockettts + sudo systemctl enable vox echo -e " ${GREEN}✓${NC} Service enabled for boot" fi read -p "Do you want to start the service now? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then - sudo systemctl start pockettts + sudo systemctl start vox echo -e " ${GREEN}✓${NC} Service started" sleep 2 echo echo " Service status:" - sudo systemctl status pockettts --no-pager || true + sudo systemctl status vox --no-pager || true fi fi @@ -199,15 +199,15 @@ echo -e "${GREEN} Setup Complete!${NC}" echo -e "${GREEN}========================================${NC}" echo echo "Useful commands:" -echo " Start bot: sudo systemctl start pockettts" -echo " Stop bot: sudo systemctl stop pockettts" -echo " Restart bot: sudo systemctl restart pockettts" -echo " View status: sudo systemctl status pockettts" -echo " View logs: journalctl -u pockettts -f" -echo " Disable boot: sudo systemctl disable pockettts" +echo " Start bot: sudo systemctl start vox" +echo " Stop bot: sudo systemctl stop vox" +echo " Restart bot: sudo systemctl restart vox" +echo " View status: sudo systemctl status vox" +echo " View logs: journalctl -u vox -f" +echo " Disable boot: sudo systemctl disable vox" echo echo "To run the bot manually (without systemd):" echo " cd $SCRIPT_DIR" echo " source venv/bin/activate" echo " python bot.py" -echo +echo \ No newline at end of file diff --git a/voices/preferences.json b/voices/preferences.json index 6edac7e..6f1f386 100644 --- a/voices/preferences.json +++ b/voices/preferences.json @@ -1,5 +1,5 @@ { "user_voices": { - "122139828182712322": "hankhill" + "122139828182712322": "gibralter_good" } } \ No newline at end of file