当前位置: 首页>>代码示例>>PHP>>正文


PHP Node::getStatus方法代码示例

本文整理汇总了PHP中Node::getStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getStatus方法的具体用法?PHP Node::getStatus怎么用?PHP Node::getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node的用法示例。


在下文中一共展示了Node::getStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stop

/**
 * Function to stop a node.
 *
 * @param   Node    $n                  Node
 * @return  int                         0 means ok
 */
function stop($n)
{
    if ($n->getStatus() != 0) {
        if ($n->getNType() == 'docker') {
            $cmd = 'docker stop ' . $n->getUuid();
        } else {
            $cmd = 'fuser -n tcp -k -TERM ' . $n->getPort() . ' > /dev/null 2>&1';
        }
        error_log('INFO: stopping ' . $cmd);
        exec($cmd, $o, $rc);
        sleep(1);
        // Need to wait a few
        if ($n->getStatus() == 0) {
            return 0;
        } else {
            // Node is still running
            error_log('ERROR: ' . $GLOBALS['messages'][80035]);
            error_log(implode("\n", $o));
            return 80035;
        }
    } else {
        return 0;
    }
}
开发者ID:qyqx,项目名称:unetlab,代码行数:30,代码来源:cli.php

示例2: stop

/**
 * Function to stop a node.
 *
 * @param   Node    $n                  Node
 * @return  int                         0 means ok
 */
function stop($n)
{
    if ($n->getStatus() != 0) {
        if ($n->getNType() == 'docker') {
            $cmd = 'docker -H=tcp://127.0.0.1:4243 stop ' . $n->getUuid();
        } else {
            $cmd = 'fuser -n tcp -k -TERM ' . $n->getPort() . ' > /dev/null 2>&1';
        }
        error_log(date('M d H:i:s ') . 'INFO: stopping ' . $cmd);
        exec($cmd, $o, $rc);
        if ($rc == 0) {
            return 0;
        } else {
            // Node is still running
            error_log(date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][80035]);
            error_log(date('M d H:i:s ') . implode("\n", $o));
            return 80035;
        }
    } else {
        return 0;
    }
}
开发者ID:dunice-valentin,项目名称:unetlab,代码行数:28,代码来源:cli.php

示例3: stop

/**
 * Function to stop a node.
 *
 * @param   Node    $n                  Node
 * @return  int                         0 means ok
 */
function stop($n)
{
    if ($n->getStatus() == 1) {
        $cmd = 'kill -s TERM $(fuser -n tcp ' . $n->getPort() . ' 2> /dev/null | sed "s/^.* \\([0-9]\\+\\)$/\\1/g")';
        exec($cmd, $o, $rc);
        error_log('INFO: stopping ' . $cmd);
        sleep(1);
        // Need to wait a few
        if ($n->getStatus() == 0) {
            return 0;
        } else {
            // Node is still running
            error_log('ERROR: ' . $GLOBALS['messages'][80035]);
            error_log(implode("\n", $o));
            return 80035;
        }
    } else {
        return 0;
    }
}
开发者ID:basscom,项目名称:unetlab,代码行数:26,代码来源:cli.php

示例4: add

 /**
  * action 'add'
  * @param Request $request
  * @param Response $response
  */
 public function add(Request $request, Response $response)
 {
     if ($request->is_post()) {
         $nid = $request->post('nid', 0);
         $ntype = $request->post('ntype');
         $title = $request->post('title', '');
         $thumb_url = $request->post('thumb_url', '');
         $match_type = $request->post('match_type', '');
         $start_date = $request->post('start_date', '');
         $end_date = $request->post('end_date', '');
         $keyword = $request->post('keyword', '');
         $slogan = $request->post('slogan', '');
         $content = $request->post('content', '');
         $content_dt = $request->post('content_detail', '');
         $status = $request->post('status', 'R');
         $ret = ['flag' => 'ERR', 'msg' => ''];
         if ('match' == $ntype) {
             if ('' == $title) {
                 $ret['msg'] = '标题不能为空';
                 $response->sendJSON($ret);
             } elseif ('' == $thumb_url) {
                 $ret['msg'] = '主图片不能为空';
                 $response->sendJSON($ret);
             }
             $match_types = Node::getMatchTypes();
             if (!in_array($match_type, array_keys($match_types))) {
                 $match_type = 'bs';
             }
         }
         $status_set = Node::getStatus();
         if (!in_array($status, array_keys($status_set))) {
             $status = 'R';
         }
         $ninfo = [];
         if ($nid) {
             $ninfo = Node::getInfo($nid);
             if (empty($ninfo)) {
                 $ret['msg'] = "Node(nid={$nid})不存在";
                 $response->sendJSON($ret);
             }
         }
         $uid = $_SESSION['logined_uid'];
         if (empty($uid)) {
             $ret['msg'] = "未登录,请重新登录";
             $response->sendJSON($ret);
         }
         $now = simphp_time();
         $params = ['ntype' => $ntype, 'title' => $title, 'content' => $content, 'keyword' => $keyword, 'createdby' => $uid, 'created' => $now, 'changedby' => $uid, 'changed' => $now, 'status' => $status];
         $allowed_ntypes = C('env.allowed_nodetypes');
         if (empty($ninfo)) {
             // new insert
             $ninfo['nid'] = D()->insert('node', $params);
             if ($ninfo['nid'] && in_array($ntype, $allowed_ntypes) && 'base' != $ntype) {
                 $params_ext = ['enid' => $ninfo['nid']];
                 switch ($ntype) {
                     case 'match':
                         $params_ext['match_type'] = $match_type;
                         $params_ext['thumb_url'] = $thumb_url;
                         $params_ext['slogan'] = $slogan;
                         $params_ext['start_date'] = $start_date;
                         $params_ext['end_date'] = $end_date;
                         $params_ext['content_detail'] = $content_dt;
                         break;
                 }
                 D()->insert('node_' . $ntype, $params_ext);
             }
             $ret['flag'] = 'OK';
             $ret['msg'] = '添加成功!';
             $response->sendJSON($ret);
         } else {
             // edit
             unset($params['createdby'], $params['created']);
             D()->update('node', $params, ['nid' => $nid]);
             if (D()->affected_rows() && in_array($ntype, $allowed_ntypes) && 'base' != $ntype) {
                 $params_ext = [];
                 switch ($ntype) {
                     case 'match':
                         $params_ext['match_type'] = $match_type;
                         $params_ext['thumb_url'] = $thumb_url;
                         $params_ext['slogan'] = $slogan;
                         $params_ext['start_date'] = $start_date;
                         $params_ext['end_date'] = $end_date;
                         $params_ext['content_detail'] = $content_dt;
                         break;
                 }
                 D()->update('node_' . $ntype, $params_ext, ['enid' => $nid]);
             }
             $ret['flag'] = 'OK';
             $ret['msg'] = '编辑成功!';
             $response->sendJSON($ret);
         }
     } else {
         // GET request
         // Node Info
         $nid = $request->arg(1);
//.........这里部分代码省略.........
开发者ID:GavinLai,项目名称:SimMatch,代码行数:101,代码来源:Node_Controller.php

示例5: show_status

 static function show_status($params)
 {
     $key = isset($params['key']) ? $params['key'] : '';
     $status_set = Node::getStatus();
     return isset($status_set[$key]) ? $status_set[$key] : '未知状态';
 }
开发者ID:GavinLai,项目名称:SimMatch,代码行数:6,代码来源:class.Tpl.php


注:本文中的Node::getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。