コード例 #1
0
    $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
コード例 #2
0
    $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