向下支持 PHP 7.4
This commit is contained in:
parent
50763da6dc
commit
92aa25cea1
@ -72,7 +72,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($redis->ping()) {
|
if ($redis->ping('')) {
|
||||||
output('redis is ok');
|
output('redis is ok');
|
||||||
}
|
}
|
||||||
} catch (RedisException $e) {
|
} catch (RedisException $e) {
|
||||||
@ -114,7 +114,7 @@ while (true) {
|
|||||||
|
|
||||||
redis_hset('nodes', $node_id, [
|
redis_hset('nodes', $node_id, [
|
||||||
'type' => 'edge',
|
'type' => 'edge',
|
||||||
'id' => $node_id,
|
'id' => 'edge-'.$node_id,
|
||||||
'ip' => $ip,
|
'ip' => $ip,
|
||||||
// utc +8 timestamp
|
// utc +8 timestamp
|
||||||
'last_heartbeat' => time(),
|
'last_heartbeat' => time(),
|
||||||
@ -152,7 +152,7 @@ while (true) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodes = redis_hgetAll('nodes', []);
|
$nodes = redis_hgetAll('nodes');
|
||||||
if (! $nodes) {
|
if (! $nodes) {
|
||||||
output('nodes is empty');
|
output('nodes is empty');
|
||||||
|
|
||||||
@ -183,9 +183,7 @@ while (true) {
|
|||||||
$temp_conf .= "server {$node['ip']}";
|
$temp_conf .= "server {$node['ip']}";
|
||||||
|
|
||||||
if (isset($node['weight'])) {
|
if (isset($node['weight'])) {
|
||||||
if ($node['weight'] === "0") {
|
if ($node['weight'] !== '0') {
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
$temp_conf .= " weight={$node['weight']} ";
|
$temp_conf .= " weight={$node['weight']} ";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -212,7 +210,7 @@ while (true) {
|
|||||||
output('!!!!!!!!!!!!!!!!!');
|
output('!!!!!!!!!!!!!!!!!');
|
||||||
|
|
||||||
$add_header = <<<EOF
|
$add_header = <<<EOF
|
||||||
add_header 'Cluster-Ready-Node-Id' '{$node_id}';
|
add_header 'Cluster-Ready-Node-Id' 'edge-$node_id';
|
||||||
add_header 'Powered-by' 'Cluster Ready!';
|
add_header 'Powered-by' 'Cluster Ready!';
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
@ -243,7 +241,7 @@ function output($context): void
|
|||||||
echo $time_string.': '.$context.PHP_EOL;
|
echo $time_string.': '.$context.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function redis_get($key, $default = null): mixed
|
function redis_get($key, $default = null)
|
||||||
{
|
{
|
||||||
global $redis, $prefix;
|
global $redis, $prefix;
|
||||||
|
|
||||||
@ -260,7 +258,7 @@ function redis_get($key, $default = null): mixed
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function redis_hget($key, $hash_key, $default = null): mixed
|
function redis_hget($key, $hash_key, $default = null)
|
||||||
{
|
{
|
||||||
global $redis, $prefix;
|
global $redis, $prefix;
|
||||||
|
|
||||||
@ -277,7 +275,7 @@ function redis_hget($key, $hash_key, $default = null): mixed
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function redis_hgetAll($key): Redis|array
|
function redis_hgetAll($key)
|
||||||
{
|
{
|
||||||
global $redis, $prefix;
|
global $redis, $prefix;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user