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:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -121,6 +121,7 @@ ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
/venv
|
||||
.numba_cache/
|
||||
# Gemini files
|
||||
GEMINI.md
|
||||
PROGRESS.md
|
||||
1
bot.py
1
bot.py
@@ -1,3 +1,4 @@
|
||||
import numba_config
|
||||
import asyncio
|
||||
import io
|
||||
from typing import Any
|
||||
|
||||
19
numba_config.py
Normal file
19
numba_config.py
Normal 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
30
setup_linux.sh
Normal file → Executable file
@@ -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,12 +199,12 @@ 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"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"user_voices": {
|
||||
"122139828182712322": "hankhill"
|
||||
"122139828182712322": "gibralter_good"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user