|
@@ -74,60 +74,64 @@ class ListeningFileCreateAction extends Action {
|
|
|
|
|
|
|
|
|
public function scan_no_listening( ){
|
|
|
- $dis = '/home/renlian';
|
|
|
- if(is_file($dir))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- $redis = new Redis();
|
|
|
- try{
|
|
|
- $redis->connect($ip,$post,2.5);
|
|
|
- $redis->auth($password); //设置密码
|
|
|
- $redis->select(1);
|
|
|
- $result = $redis->ping();
|
|
|
- if($result=='pong')
|
|
|
+ include('DahuaUtil.php');
|
|
|
+ $dir = '/home/renlian';
|
|
|
+ $ip='192.168.1.105';
|
|
|
+ $post=6379;
|
|
|
+ if(is_file($dir))
|
|
|
{
|
|
|
- echo "redis连接成功";
|
|
|
- DahuaUtil::rlog('redis连接成功');
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DahuaUtil::rlog("redis连接失败=>".$result.PHP_EOL);
|
|
|
- echo "redis连接失败=>".$result.PHP_EOL;
|
|
|
- }
|
|
|
-
|
|
|
- }catch (Exception $e){
|
|
|
-
|
|
|
- DahuaUtil::rlog("redis连接异常".$e->getMessage());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $files = scandir($dir);
|
|
|
- foreach($files as $k=>$filename) {//务必使用!==,防止目录下出现类似文件名“0”等情况
|
|
|
- if ($filename != "." && $filename != ".."&&!strstr($filename,'.redis')&&!strstr($filename,'.md5')&&is_file($dir.'/'.$filename)) {
|
|
|
- $data = $dir.'/'.$filename;
|
|
|
- $file_md5 = str_replace('.dat','.md5',$data);
|
|
|
- if(!is_file($file_md5))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- $md5=file_get_contents($file_md5);
|
|
|
- if(md5_file($data)!=$md5)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $redis = new Redis();
|
|
|
+ echo '我被唤醒了';
|
|
|
+
|
|
|
+ try{
|
|
|
+ $redis->connect($ip,$post,2.5);
|
|
|
+ $redis->auth($password); //设置密码
|
|
|
+ $redis->select(1);
|
|
|
+ $result = $redis->ping();
|
|
|
+ if($result=='+PONG')
|
|
|
+ {
|
|
|
+
|
|
|
+ DahuaUtil::rlog('redis连接成功');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DahuaUtil::rlog("redis连接失败=>".$result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception $e){
|
|
|
|
|
|
- if(rename($data,$data.'.redis'))
|
|
|
- {
|
|
|
- $redis->lpush('redis_to_kafka',$data.'.redis');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- closedir($dir);
|
|
|
- $redis->close();
|
|
|
+ DahuaUtil::rlog("redis连接异常".$e->getMessage());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $files = scandir($dir);
|
|
|
|
|
|
- return;
|
|
|
+
|
|
|
+ foreach($files as $k=>$filename) {//务必使用!==,防止目录下出现类似文件名“0”等情况
|
|
|
+
|
|
|
+ if ($filename != "." && $filename != ".." &&!strstr($filename,'.redis')&&!strstr($filename,'.md5')&&is_file($dir.'/'.$filename)) {
|
|
|
+ $data = $dir.'/'.$filename;
|
|
|
+
|
|
|
+ $file_md5 = str_replace('.dat','.md5',$data);
|
|
|
+ if(!is_file($file_md5))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(rename($data,$data.'.redis'))
|
|
|
+ {
|
|
|
+ $redis->lpush('redis_to_kafka',$data.'.redis');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closedir($dir);
|
|
|
+ $redis->close();
|
|
|
+
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
|