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.
This commit is contained in:
2026-01-18 18:09:10 -06:00
parent c69028a970
commit 736a819493
5 changed files with 38 additions and 17 deletions

1
.gitignore vendored
View File

@@ -121,6 +121,7 @@ ENV/
env.bak/ env.bak/
venv.bak/ venv.bak/
/venv /venv
.numba_cache/
# Gemini files # Gemini files
GEMINI.md GEMINI.md
PROGRESS.md PROGRESS.md

1
bot.py
View File

@@ -1,3 +1,4 @@
import numba_config
import asyncio import asyncio
import io import io
from typing import Any from typing import Any

19
numba_config.py Normal file
View File

@@ -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')}")

30
setup_linux.sh Normal file → Executable file
View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/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 # This script helps set up the bot and install it as a systemd service
set -e set -e
@@ -12,7 +12,7 @@ YELLOW='\033[1;33m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
echo -e "${GREEN}========================================${NC}" 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 -e "${GREEN}========================================${NC}"
echo echo
@@ -138,11 +138,11 @@ read -p "Do you want to install the bot as a systemd service? (y/n) " -n 1 -r
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
# Create the service file with correct paths # Create the service file with correct paths
SERVICE_FILE="/tmp/pockettts.service" SERVICE_FILE="/tmp/vox.service"
cat > "$SERVICE_FILE" << EOF cat > "$SERVICE_FILE" << EOF
[Unit] [Unit]
Description=Pocket TTS Discord Bot Description=Vox Discord Bot
After=network-online.target After=network-online.target
Wants=network-online.target Wants=network-online.target
@@ -156,7 +156,7 @@ RestartSec=10
TimeoutStopSec=30 TimeoutStopSec=30
StandardOutput=journal StandardOutput=journal
StandardError=journal StandardError=journal
SyslogIdentifier=pockettts SyslogIdentifier=vox
# Security hardening # Security hardening
NoNewPrivileges=true NoNewPrivileges=true
@@ -170,26 +170,26 @@ WantedBy=multi-user.target
EOF EOF
echo " Installing systemd service (requires sudo)..." 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 sudo systemctl daemon-reload
echo -e " ${GREEN}${NC} Service installed" echo -e " ${GREEN}${NC} Service installed"
read -p "Do you want to enable the service to start on boot? (y/n) " -n 1 -r read -p "Do you want to enable the service to start on boot? (y/n) " -n 1 -r
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo systemctl enable pockettts sudo systemctl enable vox
echo -e " ${GREEN}${NC} Service enabled for boot" echo -e " ${GREEN}${NC} Service enabled for boot"
fi fi
read -p "Do you want to start the service now? (y/n) " -n 1 -r read -p "Do you want to start the service now? (y/n) " -n 1 -r
echo echo
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo systemctl start pockettts sudo systemctl start vox
echo -e " ${GREEN}${NC} Service started" echo -e " ${GREEN}${NC} Service started"
sleep 2 sleep 2
echo echo
echo " Service status:" echo " Service status:"
sudo systemctl status pockettts --no-pager || true sudo systemctl status vox --no-pager || true
fi fi
fi fi
@@ -199,12 +199,12 @@ echo -e "${GREEN} Setup Complete!${NC}"
echo -e "${GREEN}========================================${NC}" echo -e "${GREEN}========================================${NC}"
echo echo
echo "Useful commands:" echo "Useful commands:"
echo " Start bot: sudo systemctl start pockettts" echo " Start bot: sudo systemctl start vox"
echo " Stop bot: sudo systemctl stop pockettts" echo " Stop bot: sudo systemctl stop vox"
echo " Restart bot: sudo systemctl restart pockettts" echo " Restart bot: sudo systemctl restart vox"
echo " View status: sudo systemctl status pockettts" echo " View status: sudo systemctl status vox"
echo " View logs: journalctl -u pockettts -f" echo " View logs: journalctl -u vox -f"
echo " Disable boot: sudo systemctl disable pockettts" echo " Disable boot: sudo systemctl disable vox"
echo echo
echo "To run the bot manually (without systemd):" echo "To run the bot manually (without systemd):"
echo " cd $SCRIPT_DIR" echo " cd $SCRIPT_DIR"

View File

@@ -1,5 +1,5 @@
{ {
"user_voices": { "user_voices": {
"122139828182712322": "hankhill" "122139828182712322": "gibralter_good"
} }
} }