Added xray exporter
This commit is contained in:
@@ -279,26 +279,24 @@ spec:
|
|||||||
mv /tmp/v2ray-exporter /usr/local/bin/v2ray-exporter
|
mv /tmp/v2ray-exporter /usr/local/bin/v2ray-exporter
|
||||||
chmod +x /usr/local/bin/v2ray-exporter
|
chmod +x /usr/local/bin/v2ray-exporter
|
||||||
|
|
||||||
# Wait for xray to start
|
# Wait for xray API port file from pasarguard-node container
|
||||||
echo "Waiting for xray process to start..."
|
echo "Waiting for xray API port file..."
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# Find xray API port
|
|
||||||
while true; do
|
while true; do
|
||||||
echo "Looking for xray API port..."
|
if [ -f /shared/xray-api-port ]; then
|
||||||
API_PORT=$(ss -tlpn | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1)
|
API_PORT=$(cat /shared/xray-api-port)
|
||||||
|
|
||||||
if [ -n "$API_PORT" ]; then
|
if [ -n "$API_PORT" ]; then
|
||||||
echo "Found potential API port: $API_PORT"
|
echo "Got xray API port from shared volume: $API_PORT"
|
||||||
|
|
||||||
# Verify it's the correct port
|
# Verify the port is working
|
||||||
if curl -s -o /dev/null -w "%{http_code}" "127.0.0.1:$API_PORT" 2>&1 | grep -q "Received HTTP/0.9"; then
|
if curl -s -o /dev/null -w "%{http_code}" --max-time 2 "127.0.0.1:$API_PORT" 2>&1 | grep -q "Received HTTP/0.9"; then
|
||||||
echo "Verified API port: $API_PORT"
|
echo "Verified API port: $API_PORT"
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
echo "Port verification failed, waiting..."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
echo "API port not found or not verified, retrying in 5 seconds..."
|
echo "Waiting for valid xray API port... retrying in 5 seconds"
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -332,6 +330,10 @@ spec:
|
|||||||
limits:
|
limits:
|
||||||
memory: "128Mi"
|
memory: "128Mi"
|
||||||
cpu: "100m"
|
cpu: "100m"
|
||||||
|
volumeMounts:
|
||||||
|
- name: shared-data
|
||||||
|
mountPath: /shared
|
||||||
|
readOnly: true
|
||||||
- name: pasarguard-node
|
- name: pasarguard-node
|
||||||
image: 'pasarguard/node:v0.1.1'
|
image: 'pasarguard/node:v0.1.1'
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
@@ -348,7 +350,29 @@ spec:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd /app
|
cd /app
|
||||||
exec ./main
|
|
||||||
|
# Start main process in background
|
||||||
|
./main &
|
||||||
|
MAIN_PID=$!
|
||||||
|
|
||||||
|
# Wait a bit for xray to start
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Find xray API port and save to shared volume
|
||||||
|
echo "Looking for xray API port..."
|
||||||
|
for i in {1..60}; do
|
||||||
|
API_PORT=$(ss -tlpn | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1)
|
||||||
|
if [ -n "$API_PORT" ]; then
|
||||||
|
echo "Found xray API port: $API_PORT"
|
||||||
|
echo -n "$API_PORT" > /shared/xray-api-port
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Waiting for xray API port... ($i/60)"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Continue running main process
|
||||||
|
wait $MAIN_PID
|
||||||
ports:
|
ports:
|
||||||
- name: api
|
- name: api
|
||||||
containerPort: 62050
|
containerPort: 62050
|
||||||
@@ -400,7 +424,7 @@ spec:
|
|||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: shared-data
|
- name: shared-data
|
||||||
mountPath: /shared
|
mountPath: /shared
|
||||||
readOnly: true
|
readOnly: false
|
||||||
volumes:
|
volumes:
|
||||||
- name: shared-data
|
- name: shared-data
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user