This commit is contained in:
Server
2025-07-15 03:35:15 +00:00
parent f3610a70d4
commit 7c70e03d5e
6 changed files with 380 additions and 327 deletions

View File

@@ -1,12 +0,0 @@
# API Configuration
VITE_API_URL=http://141.196.166.241:8003
# Vercel Deployment Configuration
NEXT_PUBLIC_ALLOWED_HOSTS=141.196.166.241
NEXT_PUBLIC_VERCEL_URL=${VERCEL_URL}
NODE_ENV=production
# CORS Configuration
CORS_ORIGIN=*
# Add other environment variables as needed

24
deploy.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
APP_DIR="/home/ubuntu/AyposWeb"
# Navigate to your app directory
cd "$APP_DIR" || { echo "Failed to cd to $APP_DIR"; exit 1; }
# Pull latest changes from Gitea
echo "Pulling latest code..."
git pull origin main || { echo "Git pull failed"; exit 1; }
# Build your app (change this to your build command)
# For example, npm build:
echo "Installing dependencies..."
npm install || { echo "npm install failed"; exit 1; }
echo "Building app..."
npm run build || { echo "npm build failed"; exit 1; }
# Restart your app (change this to your app's restart command)
# For example, systemctl restart myapp.service:
systemctl reload nginx || { echo "Failed to reload nginx"; exit 1; }
echo "Deployment complete"

607
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,10 @@ import {
CategoryScale, CategoryScale,
LinearScale, LinearScale,
BarElement, BarElement,
BarController,
PointElement, PointElement,
LineElement, LineElement,
LineController,
Title, Title,
Tooltip, Tooltip,
Legend, Legend,
@@ -18,8 +20,10 @@ ChartJS.register(
CategoryScale, CategoryScale,
LinearScale, LinearScale,
BarElement, BarElement,
BarController,
PointElement, PointElement,
LineElement, LineElement,
LineController,
Title, Title,
Tooltip, Tooltip,
Legend Legend
@@ -225,4 +229,4 @@ const ResourceDistributionChart: React.FC<ResourceDistributionChartProps> = ({
); );
}; };
export default ResourceDistributionChart; export default ResourceDistributionChart;

View File

@@ -898,10 +898,10 @@ const Home = () => {
migration_advices: { migration_advices: {
migration_method: migrationMethod === 'mathematical' ? 'migration_advices_la' : 'migration_advices_llm', migration_method: migrationMethod === 'mathematical' ? 'migration_advices_la' : 'migration_advices_llm',
migration_weights: { migration_weights: {
power: weights.energy.toString(), power: (weights.energy / 100).toString(),
balance: weights.balance.toString(), balance: (weights.balance / 100).toString(),
overload: weights.overload.toString(), overload: (weights.overload / 100).toString(),
allocation: weights.allocation.toString() allocation: (weights.allocation / 100).toString()
} }
}, },
block_list: blockList block_list: blockList

50
webhook_listener.py Normal file
View File

@@ -0,0 +1,50 @@
from flask import Flask, request, abort
import hmac
import hashlib
import subprocess
app = Flask(__name__)
# Optional: Add a secret token to verify webhook source
WEBHOOK_SECRET = b'Aypos-web-hook'
def verify_signature(signature_header, body):
# Implement if you want to verify the webhook signature from Gitea
if not signature_header:
return False
try:
sig_prefix, sig_hash = signature_header.split("=")
except ValueError:
return False
if sig_prefix != "sha256":
return False
# Calculate HMAC digest and compare securely
digest = hmac.new(WEBHOOK_SECRET, body, hashlib.sha256).hexdigest()
return hmac.compare_digest(digest, sig_hash)
@app.route("/webhook", methods=["POST"])
def webhook():
signature_header = request.headers.get("X-Gitea-Signature")
body = request.data
if not verify_signature(signature_header, body):
return "Invalid or missing signature", 403
event = request.headers.get("X-Gitea-Event")
if event != "push":
return "Unsupported event type", 400
try:
output = subprocess.check_output(["./deploy.sh"], stderr=subprocess.STDOUT)
print(output.decode())
return "Deployment triggered", 200
except subprocess.CalledProcessError as e:
print("Deployment error:", e.output.decode())
return "Deployment failed", 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)