|
@@ -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':{
|
281
|
- start();
|
283
|
+ $num = exec($ps);
|
|
|
284
|
+ if($num){
|
|
|
285
|
+ echo '正则运行,请勿重复运行';
|
|
|
286
|
+ }else{
|
|
|
287
|
+ start();
|
|
|
288
|
+ }
|
282
|
break;
|
289
|
break;
|
283
|
}
|
290
|
}
|
284
|
case 'stop':{
|
291
|
case 'stop':{
|
285
|
- \Co\run(function (){
|
|
|
286
|
- echo "正在退出程序...\n非必要请不要强制kill掉进程\n";
|
|
|
287
|
- redis()->set(SYNC_RUNNING_REDIS_KEY,'stop');
|
|
|
288
|
- while (true){
|
|
|
289
|
- $num = exec("ps -ef | grep \"sync.php start\" | grep -v grep | wc -l");
|
|
|
290
|
- if(!$num){
|
|
|
291
|
- break;
|
|
|
292
|
- }
|
|
|
293
|
- co::sleep(0.5);
|
292
|
+ echo "正在退出程序...\n非必要请不要强制kill掉进程\n";
|
|
|
293
|
+
|
|
|
294
|
+ redis()->set(SYNC_RUNNING_REDIS_KEY,'stop');
|
|
|
295
|
+
|
|
|
296
|
+ while (true){
|
|
|
297
|
+
|
|
|
298
|
+ $num = exec($ps);
|
|
|
299
|
+ if(!$num){
|
|
|
300
|
+ break;
|
294
|
}
|
301
|
}
|
295
|
- echo "已退出程序\n";
|
|
|
296
|
- });
|
302
|
+ sleep(1);
|
|
|
303
|
+ }
|
|
|
304
|
+ echo "已退出程序\n";
|
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
|
- |
|
|