Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/darkzOGx/youtube-automation-agent/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Deploying to a Virtual Private Server (VPS) enables true 24/7 automation without keeping your personal computer running. This is the recommended option for:
  • Production YouTube channels
  • Consistent daily uploads
  • Multiple channels management
  • Professional operations
VPS deployment costs approximately $5-20/month depending on your provider and resource needs.

VPS Provider Recommendations

DigitalOcean

$6/month - 1 GB RAM, 1 vCPU
  • Easy to use
  • Great documentation
  • 1-click deployments

Linode (Akamai)

$5/month - 1 GB RAM, 1 vCPU
  • Excellent performance
  • Strong network
  • Developer-friendly

Vultr

$6/month - 1 GB RAM, 1 vCPU
  • Global locations
  • High-frequency CPU options
  • Competitive pricing

Hetzner

€4.15/month - 2 GB RAM, 1 vCPU
  • Best price/performance
  • European datacenters
  • Excellent value

Server Requirements

Minimum Specifications

ComponentMinimumRecommended
CPU1 vCPU2 vCPUs
RAM1 GB2 GB
Storage10 GB SSD25 GB SSD
Bandwidth500 GB/month1 TB/month
OSUbuntu 20.04+Ubuntu 22.04 LTS

Estimated Costs

$6-8/month total
  • VPS: $5-6/month
  • Google Gemini API: Free
  • 1-2 videos per day
  • Perfect for starting out

Deployment Steps

1

Create VPS Instance

Choose your provider and create a new droplet/instance:DigitalOcean Example:
  1. Sign up at digitalocean.com
  2. Click “Create” → “Droplets”
  3. Choose Ubuntu 22.04 LTS
  4. Select Basic plan ($6/month)
  5. Choose datacenter region (closest to your target audience)
  6. Add SSH key for secure access
  7. Click “Create Droplet”
Save your server’s IP address - you’ll need it for SSH access
2

Connect via SSH

Connect to your VPS:
ssh root@your-server-ip
For Windows users, use PuTTY or Windows Terminal.
3

Update System Packages

apt update && apt upgrade -y
4

Install Node.js 18+

Install Node.js using NodeSource:
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt install -y nodejs
Verify installation:
node --version  # Should show v18.x.x or higher
npm --version
5

Install Git

apt install -y git
6

Install PM2 Process Manager

PM2 keeps your application running and restarts it if it crashes:
npm install -g pm2
7

Create Application User

For security, don’t run as root:
adduser youtube-agent
usermod -aG sudo youtube-agent
su - youtube-agent
8

Clone Repository

cd ~
git clone https://github.com/darkzOGx/youtube-automation-agent.git
cd youtube-automation-agent
9

Install Dependencies

npm install --production
The --production flag skips dev dependencies, saving disk space.
10

Configure Environment

Create and edit the environment file:
cp .env.example .env
nano .env
Update with your credentials:
NODE_ENV=production
PORT=3456
LOG_LEVEL=info

# AI Provider
OPENAI_API_KEY=your-openai-key
# OR
GEMINI_API_KEY=your-gemini-key

# Channel Settings
CHANNEL_NAME=Your Channel Name
DEFAULT_AUTHOR=Your Name
TARGET_AUDIENCE=Your target audience

# YouTube Settings
YOUTUBE_REGION=US
DEFAULT_PRIVACY_STATUS=public

# Security
JWT_SECRET=generate-secure-random-string-here
Save with Ctrl+X, then Y, then Enter
11

Upload YouTube Credentials

Transfer your credentials.json file from local machine to VPS:From your local machine:
scp config/credentials.json youtube-agent@your-server-ip:~/youtube-automation-agent/config/
Or create it directly on the VPS:
nano config/credentials.json
# Paste your credentials JSON
# Save with Ctrl+X, Y, Enter
12

Run Initial Setup

npm run setup
This initializes the database and verifies your configuration.
13

Start with PM2

Start the application with PM2:
pm2 start index.js --name youtube-agent
Also start the scheduler:
pm2 start schedules/daily-automation.js --name youtube-scheduler
Save the PM2 configuration:
pm2 save
14

Configure Auto-Start on Boot

Make PM2 restart on server reboot:
pm2 startup
Copy and run the command that PM2 outputs.
15

Configure Firewall

Allow necessary ports:
# Switch back to root
exit

# Configure UFW firewall
ufw allow 22/tcp      # SSH
ufw allow 3456/tcp    # Application port
ufw enable
Make sure to allow SSH (port 22) before enabling the firewall, or you’ll lock yourself out!

Setting Up Nginx Reverse Proxy (Optional)

For production deployments, use Nginx as a reverse proxy:
1

Install Nginx

apt install -y nginx
2

Configure Nginx

Create a new site configuration:
nano /etc/nginx/sites-available/youtube-agent
Add this configuration:
server {
    listen 80;
    server_name your-domain.com;  # Or use server IP
    
    location / {
        proxy_pass http://localhost:3456;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
3

Enable Site

ln -s /etc/nginx/sites-available/youtube-agent /etc/nginx/sites-enabled/
nginx -t  # Test configuration
systemctl restart nginx
4

Update Firewall

ufw allow 'Nginx Full'
ufw delete allow 3456/tcp  # No longer needed

SSL/HTTPS Setup with Let’s Encrypt (Optional)

Secure your dashboard with HTTPS:
# Install Certbot
apt install -y certbot python3-certbot-nginx

# Obtain certificate
certbot --nginx -d your-domain.com

# Auto-renewal is configured automatically

Management Commands

PM2 Commands

# View status
pm2 status

# View logs
pm2 logs youtube-agent
pm2 logs youtube-scheduler

# Restart application
pm2 restart youtube-agent

# Stop application
pm2 stop youtube-agent

# Monitor resources
pm2 monit

# View detailed info
pm2 info youtube-agent

System Monitoring

# Check disk usage
df -h

# Check memory usage
free -h

# Check CPU and processes
top
# Or use htop (install with: apt install htop)
htop

# Check network connections
netstat -tulpn | grep 3456

Database Backups

Automate database backups:
1

Create Backup Script

nano ~/backup-youtube-agent.sh
Add:
#!/bin/bash
BACKUP_DIR="$HOME/backups"
DATE=$(date +%Y%m%d_%H%M%S)

mkdir -p $BACKUP_DIR

# Backup database and config
cd ~/youtube-automation-agent
tar -czf $BACKUP_DIR/youtube-agent-$DATE.tar.gz \
  data/ config/ .env

# Keep only last 7 days of backups
find $BACKUP_DIR -name "youtube-agent-*.tar.gz" -mtime +7 -delete

echo "Backup completed: youtube-agent-$DATE.tar.gz"
Make executable:
chmod +x ~/backup-youtube-agent.sh
2

Schedule with Cron

crontab -e
Add daily backup at 3 AM:
0 3 * * * /home/youtube-agent/backup-youtube-agent.sh >> /home/youtube-agent/backup.log 2>&1

Updating the Application

# Navigate to app directory
cd ~/youtube-automation-agent

# Stop the application
pm2 stop all

# Backup current version
tar -czf ~/youtube-agent-backup-pre-update.tar.gz .

# Pull latest changes
git pull origin main

# Install any new dependencies
npm install --production

# Restart application
pm2 restart all

# Check logs for errors
pm2 logs

Monitoring and Alerts

Set Up Email Alerts

Install and configure system mail:
apt install -y mailutils

# Test email
echo "Test from YouTube Agent VPS" | mail -s "Test" your@email.com

PM2 Monitoring

PM2 can send alerts on crashes:
# Install PM2 notification module
pm2 install pm2-slack  # For Slack notifications
# Or
pm2 install pm2-discord  # For Discord notifications

Troubleshooting

Application Won’t Start

# Check PM2 logs
pm2 logs youtube-agent --lines 100

# Check system logs
journalctl -u youtube-agent -n 50

# Verify Node.js version
node --version

# Check for port conflicts
sudo netstat -tulpn | grep 3456

High Memory Usage

# Check memory
free -h

# Restart application to clear memory
pm2 restart youtube-agent

# Consider upgrading to 2GB RAM if consistently high

Database Locked Errors

# Stop all processes
pm2 stop all

# Remove lock files
rm -f data/*.db-shm data/*.db-wal

# Restart
pm2 restart all

YouTube API Authentication Issues

# Remove old tokens
rm -f data/youtube-oauth-token.json

# Re-authenticate
npm run credentials:setup

# Restart application
pm2 restart youtube-agent

Security Best Practices

1

Keep System Updated

# Set up automatic security updates
apt install -y unattended-upgrades
dpkg-reconfigure --priority=low unattended-upgrades
2

Use SSH Keys Only

Disable password authentication:
nano /etc/ssh/sshd_config
Set:
PasswordAuthentication no
PermitRootLogin no
Restart SSH:
systemctl restart sshd
3

Install Fail2Ban

Protect against brute force attacks:
apt install -y fail2ban
systemctl enable fail2ban
systemctl start fail2ban
4

Restrict File Permissions

chmod 600 .env
chmod 600 config/credentials.json
chmod 700 data/

Performance Optimization

Enable Node.js Production Mode

Already set in .env:
NODE_ENV=production

Optimize PM2 Settings

pm2 start index.js --name youtube-agent \
  --max-memory-restart 500M \
  --log-date-format="YYYY-MM-DD HH:mm:ss Z"

Database Optimization

# Run VACUUM on SQLite database monthly
sqlite3 data/youtube-automation.db "VACUUM;"

Cost Optimization Tips

Use Gemini API

Free tier handles most workloads

Smaller VPS

1GB RAM sufficient for 1-2 videos/day

Reserved Instances

Some providers offer discounts for annual payment

Optimize Schedules

Reduce frequency if hitting API limits

Next Steps

Cloud Deployment

Scale to cloud platforms for enterprise needs

Monitoring

Set up advanced monitoring and analytics

Configuration

Fine-tune your deployment

API Reference

Integrate with your custom tools

Build docs developers (and LLMs) love