예제 #1
0
파일: ajax.php 프로젝트: hshoghi/cms
     if (!is_numeric($id)) {
         $json['error'] = "bad id";
     }
     $rs = $db->Execute("select count(*) as count from repmgr_{$repmgr_cluster_name}.repl_nodes where id = {$id}");
     if ($rs->Fields('count') > 0) {
         $json['error'] = 'that id already exists';
     }
     if (!$json['error']) {
         $json[$soft = $repmgr->add_soft($cluster, $conninfo, $id) ? 'success' : 'error'] = $soft ? true : 'query_failure';
     }
     echo json_encode($json);
     break;
 case 'drop_soft':
     $node = $params['a'];
     $json = array();
     $json[$repmgr->drop_soft($node) ? 'success' : 'error'] = true;
     echo json_encode($json);
     break;
 case 'drop_hard':
     $node = $params['a'];
     $json = array('success' => $repmgr->stop_replication($node));
     echo json_encode($json);
     break;
 case 'cleanup':
     $node = $params['a'];
     $json = array('success' => 0, 'attempted' => 0);
     foreach ($repmgr->cleanup_repl_monitor($node) as $cleanup) {
         if ($cleanup) {
             $json['success']++;
         }
         $json['attempted']++;