fix: use correct server URL instead of localhost #47
@@ -82,12 +82,20 @@ EOF
|
|||||||
echo "$code"
|
echo "$code"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "ServerManager Agent started (interval: ${INTERVAL}s)"
|
echo "ServerManager Agent started"
|
||||||
|
echo " Server: $SERVER_URL/api/metrics/push"
|
||||||
|
echo " Interval: ${INTERVAL}s"
|
||||||
|
echo " Host: $(hostname)"
|
||||||
sleep 2
|
sleep 2
|
||||||
while true; do
|
while true; do
|
||||||
collect_metrics
|
collect_metrics
|
||||||
http_code=$(push_metrics)
|
http_code=$(push_metrics)
|
||||||
echo "[$(date)] HTTP $http_code"
|
echo "[$(date)] HTTP $http_code"
|
||||||
|
if [ "$http_code" = "200" ]; then
|
||||||
|
true
|
||||||
|
elif [ "$http_code" = "0" ]; then
|
||||||
|
echo " curl failed — check SERVER_URL=$SERVER_URL"
|
||||||
|
fi
|
||||||
sleep "$INTERVAL"
|
sleep "$INTERVAL"
|
||||||
done
|
done
|
||||||
AGENTSCRIPT
|
AGENTSCRIPT
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ class AgentService
|
|||||||
$serverUrl = rtrim((App::getConfig()['app']['url'] ?? ''), '/');
|
$serverUrl = rtrim((App::getConfig()['app']['url'] ?? ''), '/');
|
||||||
|
|
||||||
if (empty($serverUrl)) {
|
if (empty($serverUrl)) {
|
||||||
$serverUrl = ($_SERVER['HTTPS'] ?? '' === 'on' ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ?? 'localhost');
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
|
||||||
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
||||||
|
$serverUrl = $scheme . $host;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scriptPath = $this->basePath . '/install/agent-install.sh';
|
$scriptPath = $this->basePath . '/install/agent-install.sh';
|
||||||
|
|||||||
Reference in New Issue
Block a user