Add production deployment configuration for server 104.225.217.215:5237
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Email Alerts Deployment Script
|
||||
# Server: 104.225.217.215
|
||||
# Port: 5237
|
||||
|
||||
echo "🚀 Deploying Email Alerts Application..."
|
||||
|
||||
# Update system
|
||||
echo "📦 Updating system packages..."
|
||||
apt update && apt upgrade -y
|
||||
|
||||
# Install required packages
|
||||
echo "📦 Installing required packages..."
|
||||
apt install -y python3 python3-pip python3-venv nginx ufw
|
||||
|
||||
# Create application directory
|
||||
echo "📁 Setting up application directory..."
|
||||
mkdir -p /root/email_alerts
|
||||
cd /root/email_alerts
|
||||
|
||||
# Copy application files (assuming you'll upload them)
|
||||
echo "📋 Application files should be uploaded to /root/email_alerts/"
|
||||
|
||||
# Create virtual environment
|
||||
echo "🐍 Creating Python virtual environment..."
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
# Install dependencies
|
||||
echo "📦 Installing Python dependencies..."
|
||||
pip install flask python-dotenv requests google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client twilio groq
|
||||
|
||||
# Set up firewall
|
||||
echo "🔥 Configuring firewall..."
|
||||
ufw allow 22/tcp
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow 5237/tcp
|
||||
ufw --force enable
|
||||
|
||||
# Set up systemd service
|
||||
echo "⚙️ Setting up systemd service..."
|
||||
cp email-alerts.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable email-alerts
|
||||
systemctl start email-alerts
|
||||
|
||||
# Check service status
|
||||
echo "📊 Checking service status..."
|
||||
systemctl status email-alerts
|
||||
|
||||
echo "✅ Deployment complete!"
|
||||
echo "🌐 Application will be accessible at: http://104.225.217.215:5237"
|
||||
echo "📝 Logs available at: /root/email_alerts/email_alerts.log"
|
||||
echo ""
|
||||
echo "🔧 Useful commands:"
|
||||
echo " Start service: systemctl start email-alerts"
|
||||
echo " Stop service: systemctl stop email-alerts"
|
||||
echo " Restart service: systemctl restart email-alerts"
|
||||
echo " View logs: journalctl -u email-alerts -f"
|
||||
echo " View app logs: tail -f /root/email_alerts/email_alerts.log"
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Email Alerts Application
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/root/email_alerts
|
||||
Environment=PATH=/root/email_alerts/venv/bin
|
||||
ExecStart=/root/email_alerts/venv/bin/python /root/email_alerts/run_server.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+6
-5
@@ -1,8 +1,9 @@
|
||||
google-api-python-client==2.108.0
|
||||
Flask==3.0.0
|
||||
python-dotenv==1.0.0
|
||||
requests==2.32.4
|
||||
google-auth==2.40.3
|
||||
google-auth-oauthlib==1.1.0
|
||||
google-auth-httplib2==0.1.1
|
||||
python-dotenv==1.0.0
|
||||
groq==0.30.0
|
||||
google-api-python-client==2.108.0
|
||||
twilio==8.10.0
|
||||
requests==2.32.4
|
||||
flask==3.0.0
|
||||
groq==0.30.0
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Production server script for Email Alerts Application
|
||||
Runs on port 5237 and accessible over the internet
|
||||
"""
|
||||
|
||||
from app import app
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler('email_alerts.log'),
|
||||
logging.StreamHandler()
|
||||
]
|
||||
)
|
||||
|
||||
def auto_process_emails():
|
||||
"""Background function to automatically process emails"""
|
||||
from app import auto_process_emails as auto_process
|
||||
auto_process()
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Start auto-processing thread
|
||||
auto_thread = threading.Thread(target=auto_process_emails, daemon=True)
|
||||
auto_thread.start()
|
||||
logging.info("🔄 Auto-processing thread started")
|
||||
|
||||
# Run the Flask app in production mode
|
||||
logging.info("🚀 Starting Email Alerts server on port 5237")
|
||||
logging.info("🌐 Server will be accessible at: http://104.225.217.215:5237")
|
||||
|
||||
app.run(
|
||||
host='0.0.0.0', # Listen on all interfaces
|
||||
port=5237, # Your specified port
|
||||
debug=False, # Disable debug mode for production
|
||||
threaded=True # Enable threading for better performance
|
||||
)
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Simple startup script for Email Alerts Application
|
||||
# Server: 104.225.217.215
|
||||
# Port: 5237
|
||||
|
||||
echo "🚀 Starting Email Alerts Application..."
|
||||
|
||||
# Activate virtual environment
|
||||
source venv/bin/activate
|
||||
|
||||
# Install dependencies if needed
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Start the server
|
||||
python run_server.py
|
||||
Reference in New Issue
Block a user