<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      導(dǎo)航

      PHP win32service - Windows 系統(tǒng)后臺服務(wù)

      Posted on 2022-05-10 17:29  eastson  閱讀(132)  評論(0)    收藏  舉報

      https://www.php.net/manual/zh/book.win32service.php

      <?php
      //No timeouts, Flush Content immediatly
      set_time_limit(0);
      ob_implicit_flush();
      
      //Service Settings
      $phpPath = "D:\\PHPSTUDY\\Extensions\\php\\php7.3.4nts";
      $ServiceName = 'phpServiceName';
      $ServiceDisplay = 'phpDisplayName';
      
      //Windows Service Control
      $ServiceAction = "status";
      
      if ( isset($_GET['ServiceAction']) and strlen($_GET['ServiceAction']) ) {
          $ServiceAction = addslashes($_GET['ServiceAction']);
      } else if ( isset($argv) and isset($argv[1]) and strlen($argv[1]) ) {
          $ServiceAction = $argv[1];
      }
      
      if( $ServiceAction == "status" ) {
          $ServiceStatus = win32_query_service_status($ServiceName);
          if (is_int($ServiceStatus)) {
              echo "Error Code: 0x" . dechex($ServiceStatus) . "\nSee https://www.php.net/manual/en/win32service.constants.errors.php\n\n";
              exit;
          }
          if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_STOPPED ) {
              echo "Service Stopped\n\n";
          } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_START_PENDING ) {
              echo "Service Start Pending\n\n";
          } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_STOP_PENDING ) {
              echo "Service Stop Pending\n\n";
          } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_RUNNING ) {
              echo "Service Running\n\n";
          } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_CONTINUE_PENDING ) {
              echo "Service Continue Pending\n\n";
          } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSE_PENDING ) {
              echo "Service Pause Pending\n\n";
          } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSED ) {
              echo "Service Paused\n\n";
          } else{
              echo "Service Unknown\n\n";
          }
          exit;
      } else if ( $ServiceAction == "install" ) {
          //Install Windows Service
          $errorCode = win32_create_service( Array(
              'service' => $ServiceName,
              'display' => $ServiceDisplay,
              'params' => __FILE__ . " run",
              'path' => $phpPath . "\\php.exe",
          ));
          if ($errorCode) {
              echo "Error Code: 0x" . dechex($errorCode) . "\nSee https://www.php.net/manual/en/win32service.constants.errors.php\n\n";
          } else {
              echo "Service Installed\n\n";
          }
          exit;
      } else if ( $ServiceAction == "uninstall" ) {
          //Remove Windows Service
          $errorCode = win32_delete_service($ServiceName);
          if ($errorCode) {
              echo "Error Code: 0x" . dechex($errorCode) . "\nSee https://www.php.net/manual/en/win32service.constants.errors.php\n\n";
          } else {
              echo "Service Removed\n\n";
          }
          exit;
      } else if( $ServiceAction == "start") {
          //Start Windows Service
          $errorCode = win32_start_service($ServiceName);
          if ($errorCode) {
              echo "Error Code: 0x" . dechex($errorCode) . "\nSee https://www.php.net/manual/en/win32service.constants.errors.php\n\n";
          } else {
              echo "Service Started\n\n";
          }
          exit;
      } else if( $ServiceAction == "stop" ) {
          //Stop Windows Service
          $errorCode = win32_stop_service($ServiceName);
          if ($errorCode) {
              echo "Error Code: 0x" . dechex($errorCode) . "\nSee https://www.php.net/manual/en/win32service.constants.errors.php\n\n";
          } else {
              echo "Service Stopped\n\n";
          }
          exit;
      } else if ( $ServiceAction == "run" ) {
          //Run Windows Service
          win32_start_service_ctrl_dispatcher($ServiceName);
          win32_set_service_status(WIN32_SERVICE_RUNNING);
      } else if ( $ServiceAction == "debug" ) {
          //Debug Windows Service
          set_time_limit(10);
      } else {
          exit();
      }
      
      //Server Loop
      while (1) {
          //Handle Windows Service Request
          usleep(100*1000);
          if ( $ServiceAction == "run" ) {
              switch ( win32_get_last_control_message() ) {
                  case WIN32_SERVICE_CONTROL_CONTINUE:
                      break;
                  case WIN32_SERVICE_CONTROL_INTERROGATE:
                      win32_set_service_status(WIN32_NO_ERROR);
                      break;
                  case WIN32_SERVICE_CONTROL_STOP:
                      win32_set_service_status(WIN32_SERVICE_STOPPED);
                      exit;
                  default:
                      win32_set_service_status(WIN32_ERROR_CALL_NOT_IMPLEMENTED);
              }
          }
      
          //User Loop
          sleep(1);
      
          //YOUR CODE HERE
          echo "YOUR CODE HERE\n";
      }
      
      //Exit
      if ( $ServiceAction == "run" ) {
          win32_set_service_status(WIN32_SERVICE_STOPPED);
      }
      
      exit();
      

      注意權(quán)限問題,要以管理員身份執(zhí)行php腳本。
      可能碰到的錯誤碼:https://www.php.net/manual/en/win32service.constants.errors.php

      主站蜘蛛池模板: 苍井空浴缸大战猛男120分钟| 精品中文字幕人妻一二| 国产AV无码专区亚洲AWWW| 国产成人亚洲综合图区| 久久夜色撩人精品国产av| 欧美高清狂热视频60一70| 92久久精品一区二区| 精品国产精品中文字幕| 国产精品亚洲二区亚瑟| 日本免费视频| 国产成人精品亚洲午夜麻豆| 另类 专区 欧美 制服| 浮山县| 国产免费视频一区二区| 亚洲人成网站18禁止无码| 中文字幕国产精品av| 国产精品午夜福利清纯露脸| 97久久久亚洲综合久久| 日本一卡2卡3卡四卡精品网站| 国产69精品久久久久99尤物| 国产精品无码一区二区在线| 亚洲精品动漫一区二区三| 在线 欧美 中文 亚洲 精品| 亚洲精品乱码久久久久久| 黑人异族巨大巨大巨粗| 99久久国产福利自产拍| 人妻系列无码专区免费| 久久精品人妻无码一区二区三区| 色视频在线观看免费视频| 精品尤物TV福利院在线网站| 精品综合一区二区三区四区| 国产美女久久久亚洲综合| 精品国产欧美一区二区三区在线| 亚洲天码中文字幕第一页| 无码人妻一区二区三区线| 国产漂亮白嫩美女在线观看 | 亚洲国产青草衣衣一二三区| 亚洲一区二区中文av| 国内精品久久人妻无码妲| 日韩国产成人精品视频| 永久无码天堂网小说区|