fix: add SSL bypass and error logging to Grafana provisioning
- Add CURLOPT_SSL_VERIFYPEER=false for shared hosting environments - Add CURLOPT_FOLLOWLOCATION to handle redirects - Log all Grafana heartbeat attempts with HTTP code and cURL errors - Helps debug provisioning failures on DreamHost and similar hosts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+24
-3
@@ -839,10 +839,20 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $dsPayload);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
$response = curl_exec($ch);
|
||||
$code = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
Log::add(
|
||||
sprintf('Grafana heartbeat PUT: HTTP %d, error=%s, url=%s, dsUid=%s',
|
||||
$code, $error ?: 'none', $grafanaUrl, $dsUid),
|
||||
Log::INFO,
|
||||
'mokowaas'
|
||||
);
|
||||
|
||||
if ($code === 404)
|
||||
{
|
||||
$ch = curl_init($grafanaUrl . '/api/datasources');
|
||||
@@ -850,14 +860,25 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $dsPayload);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_exec($ch);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
$response2 = curl_exec($ch);
|
||||
$code2 = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error2 = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
Log::add(
|
||||
sprintf('Grafana heartbeat POST: HTTP %d, error=%s',
|
||||
$code2, $error2 ?: 'none'),
|
||||
Log::INFO,
|
||||
'mokowaas'
|
||||
);
|
||||
}
|
||||
|
||||
Log::add(
|
||||
'Health endpoint provisioned with Grafana on '
|
||||
. ($code === 200 ? 'update' : 'install'),
|
||||
sprintf('Grafana heartbeat result: %s (site=%s)',
|
||||
$code === 200 ? 'updated' : 'created', $siteUrl),
|
||||
Log::INFO,
|
||||
'mokowaas'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user