@@ -758,35 +758,35 @@ |
||
758 | 758 | switch($command) |
759 | 759 | { |
760 | 760 | // 启动 phpspider |
761 | - case 'start': |
|
762 | - if ($command2 === '-d') |
|
763 | - { |
|
764 | - self::$daemonize = true; |
|
765 | - } |
|
766 | - break; |
|
767 | - case 'stop': |
|
768 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
769 | - if (count($info) <= 1) |
|
770 | - { |
|
771 | - echo "PHPSpider[$start_file] not run\n"; |
|
772 | - } |
|
773 | - else |
|
774 | - { |
|
775 | - //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
776 | - echo "PHPSpider[$start_file] stop success"; |
|
777 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
778 | - } |
|
779 | - exit; |
|
780 | - break; |
|
781 | - case 'kill': |
|
782 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
783 | - break; |
|
784 | - // 显示 phpspider 运行状态 |
|
785 | - case 'status': |
|
786 | - exit(0); |
|
787 | - // 未知命令 |
|
788 | - default : |
|
789 | - exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
761 | + case 'start': |
|
762 | + if ($command2 === '-d') |
|
763 | + { |
|
764 | + self::$daemonize = true; |
|
765 | + } |
|
766 | + break; |
|
767 | + case 'stop': |
|
768 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
769 | + if (count($info) <= 1) |
|
770 | + { |
|
771 | + echo "PHPSpider[$start_file] not run\n"; |
|
772 | + } |
|
773 | + else |
|
774 | + { |
|
775 | + //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
776 | + echo "PHPSpider[$start_file] stop success"; |
|
777 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
778 | + } |
|
779 | + exit; |
|
780 | + break; |
|
781 | + case 'kill': |
|
782 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
783 | + break; |
|
784 | + // 显示 phpspider 运行状态 |
|
785 | + case 'status': |
|
786 | + exit(0); |
|
787 | + // 未知命令 |
|
788 | + default : |
|
789 | + exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
790 | 790 | } |
791 | 791 | } |
792 | 792 |
@@ -385,36 +385,36 @@ |
||
385 | 385 | { |
386 | 386 | switch($type) |
387 | 387 | { |
388 | - case E_ERROR: // 1 // |
|
389 | - return 'E_ERROR'; |
|
390 | - case E_WARNING: // 2 // |
|
391 | - return 'E_WARNING'; |
|
392 | - case E_PARSE: // 4 // |
|
393 | - return 'E_PARSE'; |
|
394 | - case E_NOTICE: // 8 // |
|
395 | - return 'E_NOTICE'; |
|
396 | - case E_CORE_ERROR: // 16 // |
|
397 | - return 'E_CORE_ERROR'; |
|
398 | - case E_CORE_WARNING: // 32 // |
|
399 | - return 'E_CORE_WARNING'; |
|
400 | - case E_COMPILE_ERROR: // 64 // |
|
401 | - return 'E_COMPILE_ERROR'; |
|
402 | - case E_COMPILE_WARNING: // 128 // |
|
403 | - return 'E_COMPILE_WARNING'; |
|
404 | - case E_USER_ERROR: // 256 // |
|
405 | - return 'E_USER_ERROR'; |
|
406 | - case E_USER_WARNING: // 512 // |
|
407 | - return 'E_USER_WARNING'; |
|
408 | - case E_USER_NOTICE: // 1024 // |
|
409 | - return 'E_USER_NOTICE'; |
|
410 | - case E_STRICT: // 2048 // |
|
411 | - return 'E_STRICT'; |
|
412 | - case E_RECOVERABLE_ERROR: // 4096 // |
|
413 | - return 'E_RECOVERABLE_ERROR'; |
|
414 | - case E_DEPRECATED: // 8192 // |
|
415 | - return 'E_DEPRECATED'; |
|
416 | - case E_USER_DEPRECATED: // 16384 // |
|
417 | - return 'E_USER_DEPRECATED'; |
|
388 | + case E_ERROR: // 1 // |
|
389 | + return 'E_ERROR'; |
|
390 | + case E_WARNING: // 2 // |
|
391 | + return 'E_WARNING'; |
|
392 | + case E_PARSE: // 4 // |
|
393 | + return 'E_PARSE'; |
|
394 | + case E_NOTICE: // 8 // |
|
395 | + return 'E_NOTICE'; |
|
396 | + case E_CORE_ERROR: // 16 // |
|
397 | + return 'E_CORE_ERROR'; |
|
398 | + case E_CORE_WARNING: // 32 // |
|
399 | + return 'E_CORE_WARNING'; |
|
400 | + case E_COMPILE_ERROR: // 64 // |
|
401 | + return 'E_COMPILE_ERROR'; |
|
402 | + case E_COMPILE_WARNING: // 128 // |
|
403 | + return 'E_COMPILE_WARNING'; |
|
404 | + case E_USER_ERROR: // 256 // |
|
405 | + return 'E_USER_ERROR'; |
|
406 | + case E_USER_WARNING: // 512 // |
|
407 | + return 'E_USER_WARNING'; |
|
408 | + case E_USER_NOTICE: // 1024 // |
|
409 | + return 'E_USER_NOTICE'; |
|
410 | + case E_STRICT: // 2048 // |
|
411 | + return 'E_STRICT'; |
|
412 | + case E_RECOVERABLE_ERROR: // 4096 // |
|
413 | + return 'E_RECOVERABLE_ERROR'; |
|
414 | + case E_DEPRECATED: // 8192 // |
|
415 | + return 'E_DEPRECATED'; |
|
416 | + case E_USER_DEPRECATED: // 16384 // |
|
417 | + return 'E_USER_DEPRECATED'; |
|
418 | 418 | } |
419 | 419 | return ""; |
420 | 420 | } |
@@ -607,35 +607,35 @@ discard block |
||
607 | 607 | switch($command) |
608 | 608 | { |
609 | 609 | // 启动 phpspider |
610 | - case 'start': |
|
611 | - if ($command2 === '-d') |
|
612 | - { |
|
613 | - self::$daemonize = true; |
|
614 | - } |
|
615 | - break; |
|
616 | - case 'stop': |
|
617 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
618 | - if (count($info) <= 1) |
|
619 | - { |
|
620 | - echo "PHPSpider[$start_file] not run\n"; |
|
621 | - } |
|
622 | - else |
|
623 | - { |
|
624 | - //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
625 | - echo "PHPSpider[$start_file] stop success"; |
|
626 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
627 | - } |
|
628 | - exit; |
|
629 | - break; |
|
630 | - case 'kill': |
|
631 | - exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
632 | - break; |
|
633 | - // 显示 phpspider 运行状态 |
|
634 | - case 'status': |
|
635 | - exit(0); |
|
636 | - // 未知命令 |
|
637 | - default : |
|
638 | - exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
610 | + case 'start': |
|
611 | + if ($command2 === '-d') |
|
612 | + { |
|
613 | + self::$daemonize = true; |
|
614 | + } |
|
615 | + break; |
|
616 | + case 'stop': |
|
617 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}'", $info); |
|
618 | + if (count($info) <= 1) |
|
619 | + { |
|
620 | + echo "PHPSpider[$start_file] not run\n"; |
|
621 | + } |
|
622 | + else |
|
623 | + { |
|
624 | + //echo "PHPSpider[$start_file] is stoping ...\n"; |
|
625 | + echo "PHPSpider[$start_file] stop success"; |
|
626 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGINT", $info); |
|
627 | + } |
|
628 | + exit; |
|
629 | + break; |
|
630 | + case 'kill': |
|
631 | + exec("ps aux | grep $start_file | grep -v grep | awk '{print $2}' |xargs kill -SIGKILL"); |
|
632 | + break; |
|
633 | + // 显示 phpspider 运行状态 |
|
634 | + case 'status': |
|
635 | + exit(0); |
|
636 | + // 未知命令 |
|
637 | + default : |
|
638 | + exit("Usage: php yourfile.php {start|stop|status|kill}\n"); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | { |
649 | 649 | switch ($signal) { |
650 | 650 | // Stop. |
651 | - case SIGINT: |
|
652 | - log::warn("Program stopping..."); |
|
653 | - self::$terminate = true; |
|
654 | - break; |
|
655 | - // Show status. |
|
656 | - case SIGUSR2: |
|
657 | - echo "show status\n"; |
|
658 | - break; |
|
651 | + case SIGINT: |
|
652 | + log::warn("Program stopping..."); |
|
653 | + self::$terminate = true; |
|
654 | + break; |
|
655 | + // Show status. |
|
656 | + case SIGUSR2: |
|
657 | + echo "show status\n"; |
|
658 | + break; |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 |