952 days continuous production uptime, 40k+ tp/s single node. Original corpo Bitbucket history not included — clean archive commit.
60 lines
2.1 KiB
PHP
60 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* launchMig.php -- help script
|
|
*
|
|
* This program is called from the: migrateData.php application as an AJAX event - the sole purpose of this script
|
|
* is to unpack the POST data from the AJAX request, and build a migration-request event broker payload.
|
|
*
|
|
* Next, we instantiate a new broker client to the migration broker and publish the migration event request - the
|
|
* output from the script is in the broker payload returned by the migration broker -- if all was successful, we'll
|
|
* output (for formatted display) the migration report -- else, we'll display the diagnostic messages.
|
|
*
|
|
*
|
|
* @author mike@givingassistant.org
|
|
* @version 1.0
|
|
*
|
|
* HISTORY:
|
|
* ========
|
|
* 10-04-18 mks DB-43: original coding
|
|
*
|
|
*/
|
|
// if this page was not called by AJAX, die
|
|
if (!$_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') die('Invalid request');
|
|
|
|
// get variables sent from client-side page
|
|
$data = isset($_POST['d']) ? (json_decode(strip_tags($_POST['d']), true)) : null;
|
|
$meta = isset($_POST['m']) ? (json_decode(strip_tags($_POST['m']), true)): null;
|
|
|
|
// output an error message if the required arrays weren't posted to the form
|
|
if (is_null($data)) {
|
|
echo ERROR_DATA_404 . $eos;
|
|
exit;
|
|
}
|
|
if (is_null($meta)) {
|
|
echo ERROR_DATA_META_404 . $eos;
|
|
exit;
|
|
}
|
|
|
|
// load namaste-light
|
|
try {
|
|
require_once(dirname(__DIR__) . '/config/sneakerstrap.inc');
|
|
} catch (ParseError | Throwable $p) {
|
|
$errorList[] = ERROR_TYPE_EXCEPTION_PARSE . $p->getMessage();
|
|
}
|
|
|
|
// todo: validate that the current Namaste config has a migration broker running...
|
|
$objMig = new gacBrokerClient(BROKER_QUEUE_M, basename(__FILE__));
|
|
if (!$objMig->status) {
|
|
echo ERROR_TEMPLATE_INSTANTIATE . BROKER_QUEUE_M . $eos;
|
|
}else {
|
|
$brokerPayload = [BROKER_REQUEST => BROKER_REQUEST_MIGRATION, BROKER_DATA => $data, BROKER_META_DATA => $meta];
|
|
$result = $objMig->call(gzcompress(json_encode($brokerPayload)));
|
|
$result = json_decode(gzuncompress($result), true);
|
|
if ($result[PAYLOAD_STATE] == true)
|
|
var_export($result[PAYLOAD_RESULTS]);
|
|
else
|
|
var_export($result[PAYLOAD_DIAGNOSTICS]);
|
|
}
|
|
if (is_object($objMig)) $objMig->__destruct();
|
|
unset($objMig);
|