|
@@ -276,24 +276,32 @@ function sync($email_id,$worker_id){ |
|
@@ -276,24 +276,32 @@ function sync($email_id,$worker_id){ |
276
|
|
276
|
|
277
|
|
277
|
|
278
|
|
278
|
|
279
|
-switch ($argv[1]){
|
279
|
+$ps = "ps -ef | grep \"sync.php start\" | grep -v grep | wc -l";
|
|
|
280
|
+
|
|
|
281
|
+switch ($argv[1]??0){
|
280
|
case 'start':{
|
282
|
case 'start':{
|
|
|
283
|
+ $num = exec($ps);
|
|
|
284
|
+ if($num){
|
|
|
285
|
+ echo '正则运行,请勿重复运行';
|
|
|
286
|
+ }else{
|
281
|
start();
|
287
|
start();
|
|
|
288
|
+ }
|
282
|
break;
|
289
|
break;
|
283
|
}
|
290
|
}
|
284
|
case 'stop':{
|
291
|
case 'stop':{
|
285
|
- \Co\run(function (){
|
|
|
286
|
echo "正在退出程序...\n非必要请不要强制kill掉进程\n";
|
292
|
echo "正在退出程序...\n非必要请不要强制kill掉进程\n";
|
|
|
293
|
+
|
287
|
redis()->set(SYNC_RUNNING_REDIS_KEY,'stop');
|
294
|
redis()->set(SYNC_RUNNING_REDIS_KEY,'stop');
|
|
|
295
|
+
|
288
|
while (true){
|
296
|
while (true){
|
289
|
- $num = exec("ps -ef | grep \"sync.php start\" | grep -v grep | wc -l");
|
297
|
+
|
|
|
298
|
+ $num = exec($ps);
|
290
|
if(!$num){
|
299
|
if(!$num){
|
291
|
break;
|
300
|
break;
|
292
|
}
|
301
|
}
|
293
|
- co::sleep(0.5);
|
302
|
+ sleep(1);
|
294
|
}
|
303
|
}
|
295
|
echo "已退出程序\n";
|
304
|
echo "已退出程序\n";
|
296
|
- });
|
|
|
297
|
break;
|
305
|
break;
|
298
|
}
|
306
|
}
|
299
|
default:{
|
307
|
default:{
|
|
@@ -309,4 +317,3 @@ switch ($argv[1]){ |
|
@@ -309,4 +317,3 @@ switch ($argv[1]){ |
309
|
|
317
|
|
310
|
|
318
|
|
311
|
|
319
|
|
312
|
- |
|
|