$json = json_decode(file_get_contents($preset), true); printf("Starting %-20s ... ", $json["id"]); $result = mo_http_request(getMOUri() . "/servers", make_ctx(getMOPresetBase() . $preset)); $decode = json_decode($result, true); if (!isset($decode["id"])) { failed($decode); } $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"]; printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap()); } echo "---\n"; foreach ($PRESETS["replicasets"] as $preset) { lap(); $json = json_decode(file_get_contents($preset), true); printf("Starting %-20s ... ", $json["id"]); $result = mo_http_request(getMOUri() . "/replica_sets", make_ctx(getMOPresetBase() . $preset)); $decode = json_decode($result, true); if (!isset($decode["id"])) { failed($decode); } $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"]; printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap()); } file_put_contents($FILENAME, json_encode($SERVERS, JSON_PRETTY_PRINT)); /* wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-AUTH wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-24 wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-26 wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/RS-two
function DELETE($id) { $opts = array("http" => array("timeout" => 60, "method" => "DELETE", "header" => "Accept: application/json\r\n", "ignore_errors" => true)); $ctx = stream_context_create($opts); $json = file_get_contents(getMOUri() . "/servers/{$id}", false, $ctx); $FILENAME = sys_get_temp_dir() . "/PHONGO-SERVERS.json"; $json = file_get_contents($FILENAME); $config = json_decode($json, true); unset($config[$id]); file_put_contents($FILENAME, json_encode($config, JSON_PRETTY_PRINT)); }
$json = json_decode(file_get_contents($preset), true); printf("Starting %-20s ... ", $json["id"]); $result = file_get_contents(getMOUri() . "/servers", false, make_ctx(getMOPresetBase() . $preset)); $decode = json_decode($result, true); if (!isset($decode["id"])) { failed($decode); } $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"]; printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap()); } echo "---\n"; foreach ($PRESETS["replicasets"] as $preset) { lap(); $json = json_decode(file_get_contents($preset), true); printf("Starting %-20s ... ", $json["id"]); $result = file_get_contents(getMOUri() . "/replica_sets", false, make_ctx(getMOPresetBase() . $preset)); $decode = json_decode($result, true); if (!isset($decode["id"])) { failed($decode); } $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"]; printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap()); } file_put_contents($FILENAME, json_encode($SERVERS, JSON_PRETTY_PRINT)); /* wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-AUTH wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-24 wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-26 wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/RS-two