feat: canonical URLs, alias heartbeats, package migration, cleanup
Joomla: Repo Health / Access control (push) Successful in 1s
Joomla: Update Server / Update updates.xml (push) Failing after 13m55s
Joomla: Repo Health / Scripts governance (push) Successful in 4s
Joomla: Repo Health / Repository health (push) Failing after 4s
Joomla: Repo Health / Release configuration (push) Failing after 5s

- manifest.xml: package-type plugin → package
- Canonical URL injection for alias domains (prevents SEO duplication)
- Heartbeat registration for alias domains (each alias gets Grafana datasource)
- Package script.php: enable plugins on every install/update, heartbeat on postflight
- Remove accidentally committed profile.ps1 and TODO.md
- Add profile.ps1 and TODO.md to .gitignore

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-24 03:46:05 -05:00
parent ffd98a19d9
commit c6475ff29a
6 changed files with 112 additions and 30 deletions
+71 -6
View File
@@ -15,7 +15,8 @@ use Joomla\CMS\Log\Log;
/**
* Package installation script for MokoWaaS.
*
* Auto-enables the system plugin and webservices plugin after install.
* Handles migration from standalone plugin to package, enables plugins,
* and triggers heartbeat registration on install/update.
*
* @since 2.2.0
*/
@@ -33,11 +34,11 @@ class Pkg_MokowaasInstallerScript
*/
public function postflight($type, $parent)
{
if ($type === 'install' || $type === 'discover_install')
{
$this->enablePlugin('system', 'mokowaas');
$this->enablePlugin('webservices', 'mokowaas');
}
$this->enablePlugin('system', 'mokowaas');
$this->enablePlugin('webservices', 'mokowaas');
// Trigger heartbeat registration
$this->sendHeartbeat();
}
/**
@@ -69,4 +70,68 @@ class Pkg_MokowaasInstallerScript
Log::add('Error enabling plugin ' . $group . '/' . $element . ': ' . $e->getMessage(), Log::WARNING, 'jerror');
}
}
/**
* Send heartbeat to the MokoWaaS monitoring receiver.
*
* @return void
*
* @since 02.03.08
*/
private function sendHeartbeat(): void
{
try
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('params'))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('element') . ' = ' . $db->quote('mokowaas'))
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('system'));
$params = json_decode((string) $db->setQuery($query)->loadResult());
$healthToken = $params->health_api_token ?? '';
if (empty($healthToken))
{
return;
}
$siteUrl = rtrim(\Joomla\CMS\Uri\Uri::root(), '/');
$siteName = Factory::getConfig()->get('sitename', 'Joomla');
$payload = json_encode([
'site_url' => $siteUrl,
'site_name' => $siteName,
'health_token' => $healthToken,
'action' => 'register',
], JSON_UNESCAPED_SLASHES);
$ch = curl_init('https://bench.mokoconsulting.tech/api/waas-heartbeat/register');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-MokoWaaS-Key: moko-waas-hb-2026-x9k4m',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
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);
curl_close($ch);
if ($code >= 200 && $code < 300)
{
Factory::getApplication()->enqueueMessage('Grafana heartbeat: site registered', 'message');
}
}
catch (\Throwable $e)
{
// Silent failure — heartbeat is non-critical
}
}
}