Install app as a service. Update application upon deployment without destroing it. Added elastic ip
Some checks failed
AWS Deploy on Push / build (push) Failing after 4m0s
Some checks failed
AWS Deploy on Push / build (push) Failing after 4m0s
This commit is contained in:
@@ -97,8 +97,15 @@ class IptvUpdaterStack(Stack):
|
||||
user_data=userdata,
|
||||
)
|
||||
|
||||
# Create Elastic IP
|
||||
eip = ec2.CfnEIP(
|
||||
self, "IptvUpdaterEIP",
|
||||
domain="vpc",
|
||||
instance_id=instance.instance_id
|
||||
)
|
||||
|
||||
# Output the public DNS name
|
||||
CfnOutput(
|
||||
self, "InstancePublicDNS",
|
||||
value=instance.instance_public_dns_name
|
||||
value=eip.attr_public_ip
|
||||
)
|
||||
@@ -14,8 +14,26 @@ cd iptv-updater-aws
|
||||
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
# Create systemd service file
|
||||
cat << 'EOF' > /etc/systemd/system/iptv-updater.service
|
||||
[Unit]
|
||||
Description=IPTV Updater Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=ec2-user
|
||||
WorkingDirectory=/home/ec2-user/iptv-updater-aws
|
||||
ExecStart=/usr/local/bin/uvicorn app.main:app --host 127.0.0.1 --port 8000
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Create nginx config
|
||||
echo 'server {
|
||||
cat << 'EOF' > /etc/nginx/conf.d/iptvUpdater.conf
|
||||
server {
|
||||
listen 80;
|
||||
server_name $HOSTNAME;
|
||||
location / {
|
||||
@@ -25,11 +43,11 @@ echo 'server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}' > /etc/nginx/conf.d/iptvUpdater.conf
|
||||
}
|
||||
EOF
|
||||
|
||||
# Start nginx service
|
||||
systemctl enable nginx
|
||||
systemctl start nginx
|
||||
|
||||
# Start IptvUpdater on port 8000
|
||||
nohup uvicorn app.main:app --host 127.0.0.1 --port 8000 </dev/null &>/dev/null &
|
||||
systemctl enable iptv-updater
|
||||
systemctl start iptv-updater
|
||||
Reference in New Issue
Block a user