国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

想把workerman改成WINDOWS服務(wù)程序可行嗎?方案如下。

tmig

workerman在WINDOWS下用命令行啟動,有點不方便。想改成WINDOWS服務(wù)程序方式運行.
想法如下:
1,下載PHP的擴(kuò)展:php_win32service.dll
2,在Select.php中修改:

public function loop()
{
    $e = null;
    while (1)
    {
        ....
    }
}

改成:

public function loop()
{
    $e = null;
    while (1) {
        if (WIN32_SERVICE_CONTROL_STOP == win32_get_last_control_message()) {
            die("服務(wù)已停止!");
        }

    }
}

不知道可行不?如果可行對性能有影響沒?

4494 5 0
5個回答

walkor 打賞

贊!
性能影響應(yīng)該不大。你可以寫個腳本單獨壓測下
WIN32_SERVICE_CONTROL_STOP == win32_get_last_control_message()
試下,看每秒能運行多少次。
另外=== 比 == 性能要高一些

  • 暫無評論
tmig

查看PHP官方文檔:

//檢測服務(wù)是否存在
if (!win32_start_service_ctrl_dispatcher( _SERVICENAME )) {
 die("沒有發(fā)現(xiàn)正在運行的  服務(wù)");
}
win32_set_service_status(WIN32_SERVICE_RUNNING);

//如果運行中
while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) 
{
 # do your work here.
 # try not to take up more than 30 seconds before going around the loop
 # again
}

知道這個while要寫到哪里去!Select.php文件在的loop中修改通不過!
版主幫幫寫下!

  • 暫無評論
tmig

官方的例子:

<?php

class TestClass {
    private $args;

    function __construct($arg) {
        $this->args = $arg;
        $this->run();
    }

    private function run() {
        if ($this->args == 'run') {
            win32_start_service_ctrl_dispatcher('test_service');

            while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
                # do your work here.
                # try not to take up more than 30 seconds before going around the loop
                # again
            }
        }
    }
}

$object = new TestClass($argv);

?>
  • 暫無評論
tmig

問題決解了!
寫了個空殼的服務(wù)程序,在里面直接執(zhí)行php.exe start.php
停止服務(wù)時!KILL掉PHP.EXE的進(jìn)程。
已穩(wěn)定運行兩周了。
再為不為在WINDOWS平臺下要登陸系統(tǒng)在命令行運行的煩惱!
[attach]172[/attach]

  • 暫無評論
walkor 打賞

  • 暫無評論
年代過于久遠(yuǎn),無法發(fā)表回答
??

<blockquote id="a5dza"></blockquote>
<mark id="a5dza"></mark>

<mark id="a5dza"><strong id="a5dza"></strong></mark>