Changed project name to be IPTV Manager Service
All checks were successful
AWS Deploy on Push / build (push) Successful in 8m29s
All checks were successful
AWS Deploy on Push / build (push) Successful in 8m29s
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
# Update system and install required packages
|
||||
dnf update -y
|
||||
dnf install -y python3-pip git cronie nginx certbot python3-certbot-nginx
|
||||
dnf install -y python3-pip git cronie nginx certbot python3-certbot-nginx postgresql awscli
|
||||
|
||||
# Start and enable crond service
|
||||
systemctl start crond
|
||||
@@ -11,27 +11,48 @@ systemctl enable crond
|
||||
cd /home/ec2-user
|
||||
|
||||
git clone ${REPO_URL}
|
||||
cd iptv-updater-aws
|
||||
cd iptv-manager-service
|
||||
|
||||
# Install Python packages with --ignore-installed to prevent conflicts with RPM packages
|
||||
pip3 install --ignore-installed -r requirements.txt
|
||||
|
||||
# Retrieve DB credentials from SSM Parameter Store
|
||||
export DB_HOST=$(aws ssm get-parameter --name "/iptv-manager/DB_HOST" --query "Parameter.Value" --output text)
|
||||
export DB_NAME=$(aws ssm get-parameter --name "/iptv-manager/DB_NAME" --query "Parameter.Value" --output text)
|
||||
export DB_USER=$(aws ssm get-parameter --name "/iptv-manager/DB_USER" --query "Parameter.Value" --output text)
|
||||
export DB_PASSWORD=$(aws ssm get-parameter --name "/iptv-manager/DB_PASSWORD" --query "Parameter.Value" --output text)
|
||||
|
||||
# Set PGPASSWORD for psql to use
|
||||
export PGPASSWORD=$DB_PASSWORD
|
||||
|
||||
# Wait for PostgreSQL to be ready
|
||||
echo "Waiting for PostgreSQL to start..."
|
||||
until psql -h $DB_HOST -U $DB_USER -d postgres -c '\q'; do
|
||||
sleep 1
|
||||
done
|
||||
echo "PostgreSQL is ready."
|
||||
|
||||
# Create database if it does not exist
|
||||
DB_EXISTS=$(psql -h $DB_HOST -U $DB_USER -d postgres -tc "SELECT 1 FROM pg_database WHERE datname = '$DB_NAME';")
|
||||
if [ -z "$DB_EXISTS" ]; then
|
||||
echo "Creating database $DB_NAME..."
|
||||
psql -h $DB_HOST -U $DB_USER -d postgres -c "CREATE DATABASE $DB_NAME;"
|
||||
echo "Database $DB_NAME created."
|
||||
fi
|
||||
|
||||
# Run database migrations
|
||||
alembic upgrade head
|
||||
|
||||
# Seed initial priorities
|
||||
python3 -c "from app.utils.database import SessionLocal; from app.models.db import Priority; db = SessionLocal(); db.add_all([Priority(id=100, description='High'), Priority(id=200, description='Medium'), Priority(id=300, description='Low')]); db.commit()"
|
||||
|
||||
# Create systemd service file
|
||||
cat << 'EOF' > /etc/systemd/system/iptv-updater.service
|
||||
cat << 'EOF' > /etc/systemd/system/iptv-manager.service
|
||||
[Unit]
|
||||
Description=IPTV Updater Service
|
||||
Description=IPTV Manager Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=ec2-user
|
||||
WorkingDirectory=/home/ec2-user/iptv-updater-aws
|
||||
WorkingDirectory=/home/ec2-user/iptv-manager-service
|
||||
ExecStart=/usr/local/bin/uvicorn app.main:app --host 127.0.0.1 --port 8000
|
||||
EnvironmentFile=/etc/environment
|
||||
Restart=always
|
||||
@@ -56,7 +77,7 @@ sudo mkdir -p /etc/nginx/ssl
|
||||
--reloadcmd "service nginx force-reload"
|
||||
|
||||
# Create nginx config
|
||||
cat << EOF > /etc/nginx/conf.d/iptvUpdater.conf
|
||||
cat << EOF > /etc/nginx/conf.d/iptvManager.conf
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${DOMAIN_NAME} *.${DOMAIN_NAME};
|
||||
@@ -83,5 +104,5 @@ EOF
|
||||
# Start nginx service
|
||||
systemctl enable nginx
|
||||
systemctl start nginx
|
||||
systemctl enable iptv-updater
|
||||
systemctl start iptv-updater
|
||||
systemctl enable iptv-manager
|
||||
systemctl start iptv-manager
|
||||
Reference in New Issue
Block a user