本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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);
//.........这里部分代码省略.........
示例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] : '未知状态';
}