本文整理汇总了PHP中Daemon::daemonize方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::daemonize方法的具体用法?PHP Daemon::daemonize怎么用?PHP Daemon::daemonize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::daemonize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: debug
<?php
require __DIR__ . "/../../../server/lib/Daemon.php";
Daemon::daemonize(__DIR__ . "/proxy.pid");
function debug($what1, $what2 = false)
{
echo $what1 . ": ";
echo $what2;
echo "\n";
}
class XDebugServer
{
public $serverPort = 9000;
public $serverSocket = false;
public $clientPort = 9001;
public $clientSocket = false;
public $clients;
public $lastClient;
public $clientTimeout = 2;
public $daemonTimeout = 10;
public $apiPaths;
function init()
{
$this->serverSocket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Failed creating server socket: " . socket_strerror(socket_last_error()));
socket_set_option($this->serverSocket, SOL_SOCKET, SO_REUSEADDR, 1) or die("Failed setting option on server socket: " . socket_strerror(socket_last_error()));
socket_bind($this->serverSocket, "0.0.0.0", $this->serverPort) or die("Failed binding server socket (" . $this->serverPort . "): " . socket_strerror(socket_last_error()));
socket_listen($this->serverSocket) or die("Failed listening server socket: " . socket_strerror(socket_last_error()));
$this->clientSocket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Failed creating client socket: " . socket_strerror(socket_last_error()));
socket_set_option($this->clientSocket, SOL_SOCKET, SO_REUSEADDR, 1) or die("Failed setting option on client socket: " . socket_strerror(socket_last_error()));
socket_bind($this->clientSocket, "0.0.0.0", $this->clientPort) or die("Failed binding client socket (" . $this->idePort . "): " . socket_strerror(socket_last_error()));
socket_listen($this->clientSocket) or die("Failed listening client socket: " . socket_strerror(socket_last_error()));
示例2: onIdle
<?php
require __DIR__ . "/../../../server/lib/Daemon.php";
Daemon::daemonize(__DIR__ . "/server.pid");
spl_autoload_register(function ($name) {
require_once __DIR__ . "/" . str_replace("\\", "/", $name) . ".php";
});
use Symfony\Component\Process\Process;
include "SocketServer.php";
class Listener implements SocketListener
{
public function onIdle(SocketServer $server)
{
$clients = $server->getClients();
foreach ($clients as $client) {
if ($client->buffer) {
$client->send(array('type' => 'shell', 'result' => $client->buffer));
$client->buffer = "";
}
if ($client->process && !$client->process->isRunning() && !$client->buffer) {
$client->process = false;
$client->send(array('type' => 'shell', 'finished' => true));
}
}
usleep(1000 * 10);
}
function parseCookies($line)
{
$aPairs = explode(';', $line);
$result = array();
foreach ($aPairs as $pair) {