Browse Source

add: refresh

Ben 11 months ago
parent
commit
58fdb5f74d
2 changed files with 22 additions and 1 deletions
  1. 20 0
      app.py
  2. 2 1
      requirements.txt

+ 20 - 0
app.py

@@ -1,5 +1,6 @@
 import logging
 
+import boto3
 import cachetools
 import yt_dlp
 from flask import Flask, request
@@ -96,5 +97,24 @@ def health():
     }
 
 
+@app.route("/refresh", methods=["GET"])
+def refresh():
+    autoscaling = boto3.client(
+        'autoscaling',
+        region_name="us-east-1",
+        aws_access_key_id="AKIA2TBT2JUNG6X3W737",
+        aws_secret_access_key="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")
+    response = autoscaling.start_instance_refresh(
+        AutoScalingGroupName="be-ytb-as",
+        Strategy="Rolling",
+        Preferences={
+            "MinHealthyPercentage": 110,
+            "InstanceWarmup": 120
+        })
+    return {
+        "response": response
+    }
+
+
 if __name__ == '__main__':
     app.run(host='0.0.0.0', port=80, debug=True)

+ 2 - 1
requirements.txt

@@ -3,4 +3,5 @@ Flask==2.3.2
 Flask_Cors==3.0.10
 Requests==2.31.0
 yt_dlp==2024.4.9
-cachetools==4.2.4
+cachetools==4.2.4
+boto3==1.28.1