Asynchronous server-side framework for network applications implemented in PHP using libevent

Related tags

Frameworks phpdaemon
Overview

phpDaemon

Build Status

https://github.com/kakserpom/phpdaemon

Asynchronous framework in PHP. It has a huge number of features. Designed for highload. Each worker is capable of handling thousands of simultaneous connections. Main features and possibilites:

  • Powerful servers: HTTP, FastCGI, FlashPolicy, Ident, Socks4/5.
  • Many bundled clients like DNS, MySQL, Postgresql, Memcache, MongoDB, Redis, HTTP, IRC, Jabber, ICMP, Valve games client, etc.
  • Asynchrounous Filesystem I/O (using eio).
  • Many useful built-in applications like CGI.
  • Interactive debug console.
  • Dynamic spawning workers.
  • Chroot & Chdir for workers.
  • Automatic graceful reloading user's scripts when it's updated.
  • Graceful worker shutdown (and re-spawn if necessary) by the following limits: memory, query counter, idle time.

Master process understands signals:

SIGINT, SIGTERM, SIGQUIT - termination.
SIGHUP - update config from file.
SIGUSR1 - reopen log-file.
SIGUSR2 - graceful restart all workers.

Mail listing: [email protected] Maintainer: [email protected] Web-site: http://daemon.io/

Comments
  • namespace nightmare

    namespace nightmare

    Стандартные функции PHP переопределяются в пространстве имен PHPDaemon\Thread

    для обхода проблемы приходится использовать следущий хак:

    runkit_function_rename('PHPDaemon\Thread\header', 'header'); runkit_function_rename('PHPDaemon\Thread\headers_sent', 'headers_sent'); runkit_function_rename('PHPDaemon\Thread\is_uploaded_file', 'is_uploaded_file'); runkit_function_rename('PHPDaemon\Thread\move_uploaded_file', 'move_uploaded_file'); runkit_function_rename('PHPDaemon\Thread\is_uploaded_file', 'is_uploaded_file'); runkit_function_rename('PHPDaemon\Thread\headers_list', 'headers_list'); runkit_function_rename('PHPDaemon\Thread\setcookie', 'setcookie'); runkit_function_rename('PHPDaemon\Thread\register_shutdown_function', 'register_shutdown_function'); runkit_function_rename('PHPDaemon\Thread\create_function', 'create_function');

    ..........................................................

    namespace PHPDaemon\Thread;

    /**
     * Overrides native PHP functions.
     * @return void
     */
    protected function overrideNativeFuncs() {
        if (Daemon::supported(Daemon::SUPPORT_RUNKIT_INTERNAL_MODIFY)) {
    
            runkit_function_rename('header', 'header_native');
    
            function header() {
                if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
                    return false;
                }
                return call_user_func_array([Daemon::$context, 'header'], func_get_args());
            }
    
    opened by andrey-oparin 18
  • Hangs when not in use for a long time

    Hangs when not in use for a long time

    Hi. I've set up chat server using phpDaemon and WebSockets. It's not published yet so is only used by test users. I've noticed that if I don't connect and send any messages for about 2 days it hangs, clients cannot connect and phpd restart is needed. Is there any way to fix or track it?

    opened by yefrem 11
  • SockJS\Examples\Simple и протоколы кроме WebSocket

    SockJS\Examples\Simple и протоколы кроме WebSocket

    Не смог добиться корректной работы дефолтного примера, если ограничить транспорты, исключив WebSocket. С ними все отлично.

    Для примера, модифицируем SimpleRequest.php:

    sock = new SockJS('http://'+document.domain+':8068/sockjs/', null, {protocols_whitelist: ['jsonp-polling']});

    Так мы оставим только один протокол (jsonp-polling). После старта, идет запрос и он сразу закрывается, больше клиент не делает запросов никаких. При этом на сервере на первый взгляд все корректно, обработчик Methods\Jsonp.php отрабатывает.

    Тестировал как на дефолной версии 0.3.4, так и на последней 1.0.3

    opened by aleksraiden 10
  • Warning: shmop_open(): unable to attach or create shared memory segment in (критичный баг)

    Warning: shmop_open(): unable to attach or create shared memory segment in (критичный баг)

    [Tue, 13 Jan 2015 06:04:26.594018 +0400] read 1024 from segno #4070 [Tue, 13 Jan 2015 06:04:26.594896 +0400] Warning: shmop_open(): unable to attach or create shared memory segment in /home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Utils/ShmEntity.php:83 #1 PHPDaemon\Core\Daemon::errorHandler() #2 shmop_open() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Utils/ShmEntity.php:83] #3 PHPDaemon\Utils\ShmEntity->open() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Utils/ShmEntity.php:155] #4 PHPDaemon\Utils\ShmEntity->read() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Core/Daemon.php:626] #5 PHPDaemon\Core\Daemon::getStateOfWorkers() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:139] #6 PHPDaemon\Thread\Master->callMPM() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:96] #7 PHPDaemon\Thread\Master->PHPDaemon\Thread{closure}() #8 call_user_func() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Core/Timer.php:81] #9 PHPDaemon\Core\Timer->eventCall() #10 EventBase->dispatch() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Worker.php:254] #11 PHPDaemon\Thread\Worker->run() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Generic.php:126] #12 PHPDaemon\Thread\Generic->__invoke() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/bin/phpd:69]

    [Tue, 13 Jan 2015 06:04:26.594980 +0400] Stopping 2 worker(s) [Tue, 13 Jan 2015 06:04:26.595051 +0400] --2-- #1 PHPDaemon\Thread\Master->stopWorkers() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:176] #2 PHPDaemon\Thread\Master->callMPM() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:96] #3 PHPDaemon\Thread\Master->PHPDaemon\Thread{closure}() #4 call_user_func() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Core/Timer.php:81] #5 PHPDaemon\Core\Timer->eventCall() #6 EventBase->dispatch() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Worker.php:254] #7 PHPDaemon\Thread\Worker->run() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Generic.php:126] #8 PHPDaemon\Thread\Generic->__invoke() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/bin/phpd:69]

    из-за этой ошибки иногда он вешается на мертво только killall -9 php спасает, правда если приложение легкое то он нормально работает так как после 1k вызов он автоматом перезагружается приложение... но вмоем случае это критический баг он тупа открывает сегметы до 4070 смотреть выше(лог) , может я что не понимаю, или где не прочел инструкцию. я и вручную gc запускал после выполнение запроса, через htop выдно что cpu под 100% ,каждый воркер жрал а вмоем случаю 2,выснул и не на что не отвечал для разработчиков матерал №1 для разработчиков материал №2 Version PHP-5.5.9

    Constants PHP Prefix: /home/alex/.phpbrew/php/php-5.5.9 PHP Binary: /home/alex/.phpbrew/php/php-5.5.9/bin/php PHP Default Include path: .:/home/alex/.phpbrew/php/php-5.5.9/lib/php PHP Include path: .:/home/alex/.phpbrew/php/php-5.5.9/lib/php

    General Info phpinfo() PHP Version => 5.5.9

    System => Linux alex-P5QL-PRO 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 Build Date => Jan 11 2015 00:29:11 Configure Command => './configure' '--prefix=/home/alex/.phpbrew/php/php-5.5.9' '--with-config-file-path=/home/alex/.phpbrew/php/php-5.5.9/etc' '--with-config-file-scan-dir=/home/alex/.phpbrew/php/php-5.5.9/var/db' '--with-pear=/home/alex/.phpbrew/php/php-5.5.9/lib/php' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-zlib=/usr' '--enable-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--with-libxml-dir=/usr' '--with-pcre-regex' '--with-pcre-dir=/usr' '--enable-sockets' '--with-mhash=/usr' '--enable-json' '--with-curl=/usr' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-posix' '--enable-dom' '--enable-ctype' '--enable-mbstring' '--enable-mbregex' '--with-mcrypt=/usr' '--enable-filter' '--with-openssl=/usr' '--enable-pcntl' '--enable-pdo' '--with-libdir=lib/x86_64-linux-gnu' '--enable-maintainer-zts' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => /home/alex/.phpbrew/php/php-5.5.9/etc Loaded Configuration File => /home/alex/.phpbrew/php/php-5.5.9/etc/php.ini Scan this dir for additional .ini files => /home/alex/.phpbrew/php/php-5.5.9/var/db Additional .ini files parsed => /home/alex/.phpbrew/php/php-5.5.9/var/db/eio.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/event.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/gd.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/gearman.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/inotify.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/mongo.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/proctitle.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/redis.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/runkit.ini

    PHP API => 20121113 PHP Extension => 20121212 Zend Extension => 220121212 Zend Extension Build => API220121212,TS PHP Extension Build => API20121212,TS Debug Build => no Thread Safety => enabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring IPv6 Support => enabled DTrace Support => disabled

    Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls Registered Stream Filters => zlib., mcrypt., mdecrypt., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, dechunk

    This program makes use of the Zend Scripting Language Engine: Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

    Extensions Core, date, ereg, libxml, openssl, pcre, zlib, ctype, curl, dom, filter, hash, json, mbstring, mcrypt, SPL, session, pcntl, standard, PDO, mysqlnd, Phar, posix, Reflection, pdo_mysql, shmop, SimpleXML, sockets, mysqli, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlwriter, xsl, eio, event, gd, gearman, inotify, mongo, proctitle, redis, runkit, mhash

    Database Extensions PDO mysqlnd pdo_mysql mysqli

    p.s.: если что-то нужно скинуть скажите skype:setis-0 jid:[email protected]

    opened by setis 10
  • Problems with autoloading

    Problems with autoloading

    Hi

    I have included this in my composer.json file for my project:

        "repositories" : [{
                "name" : "phpdaemon",
                "type" : "package",
                "url" : "https://github.com/kakserpom/phpdaemon",
                "package" : {
                    "name" : "phpdaemon",
                    "version" : "master",
                    "source" : {
                        "type" : "git",
                        "url" : "[email protected]:kakserpom/phpdaemon.git",
                        "reference" : "master"
                    }
                }
            }
        ]
    

    and added ("phpdaemon" : "master") to my list of required packages.

    composer adds phpdaemon to my vendor dir as expected but it seem like the autoload part is not working because the following causes a class not found error when I try to use the code in my application.

    namespace My\Namespace;
    use PHPDaemon\Core\AppInstance;
    
    class Daemon extends \PHPDaemon\Core\AppInstance
    {
    }
    

    Any hints?

    opened by localgod 10
  • uncontrollable worker processes spawn

    uncontrollable worker processes spawn

    Hi,

    We are using FastCGI servers only. Sometimes by some unknown reason phpdaemon start to spawn new workers without control, despite the limit in the config file. This ends up in a out of memory and OS goes down.

    I'm attaching logs, please note the timestamp, in the end the workers have no chance to die during this short timeframe.

    Could you please help me to resolve this issue or point to what the problem could be?

    phpdaemon version: 1.0-beta3 (was updated today, 6 March)

    phpinfo System => Linux api-01 2.6.32-358.18.1.el6.centos.plus.x86_64 #1 SMP Wed Aug 28 16:14:04 UTC 2013 x86_64 Build Date => Oct 2 2013 16:17:31 Configure Command => './configure' '--prefix=/srv/php' '--with-config-file-path=/srv/php/etc' '--enable-mbstring' '--enable-fpm' '--with-fpm-user=php' '--with-fpm-group=php' '--with-mysql' '--with-gd' '--with-jpeg-dir=/usr/' '--with-openssl' '--enable-pcntl' '--with-curl' '--enable-libxml' '--with-libxml-dir' '--enable-xmlwriter' '--enable-xmlreader' '--enable-xml' '--enable-posix' '--enable-bcmath' '--enable-json' '--with-pgsql' '--without-pear' '--enable-sockets' '--enable-shmop' '--enable-zip' Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /srv/php/etc Loaded Configuration File => /srv/php/etc/php.ini Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) PHP API => 20100412 PHP Extension => 20100525 Zend Extension => 220100525 Zend Extension Build => API220100525,NTS PHP Extension Build => API20100525,NTS Debug Build => no Thread Safety => disabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring IPv6 Support => enabled DTrace Support => disabled

    eio eio support => enabled Debug support => disabled Version => 1.2.3

    event event support => enabled Debug support => disabled Extra functionality support including HTTP, DNS, and RPC => enabled OpenSSL support => enabled Thread safety support => disabled Version => 1.7.3

    Thanks!!! Logs starts here: This is where everything goes just fine:

    [Thu, 6 Mar 2014 17:55:25.357339 +0000] M#31248 Spawning worker-replacer for reloaded worker #1004 [Thu, 6 Mar 2014 17:55:25.666464 +0000] W#4882 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:27.905212 +0000] W#4786 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:28.073531 +0000] M#31248 Spawning worker-replacer for reloaded worker #1002 [Thu, 6 Mar 2014 17:55:28.217885 +0000] W#4884 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:28.564890 +0000] W#4684 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:29.133475 +0000] M#31248 Spawning worker-replacer for reloaded worker #978 [Thu, 6 Mar 2014 17:55:29.439365 +0000] W#4886 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:37.812265 +0000] W#4532 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:38.029016 +0000] M#31248 Spawning worker-replacer for reloaded worker #951 [Thu, 6 Mar 2014 17:55:38.327381 +0000] W#4930 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:38.771934 +0000] W#4540 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:39.235271 +0000] M#31248 Spawning worker-replacer for reloaded worker #955 [Thu, 6 Mar 2014 17:55:39.540215 +0000] W#4932 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:41.137304 +0000] Spawning 1 worker(s) [Thu, 6 Mar 2014 17:55:41.442150 +0000] W#4936 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:42.402186 +0000] Spawning 2 worker(s) [Thu, 6 Mar 2014 17:55:42.705692 +0000] W#4938 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:42.706157 +0000] W#4939 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:43.284194 +0000] W#4550 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:43.616367 +0000] M#31248 Spawning worker-replacer for reloaded worker #959 [Thu, 6 Mar 2014 17:55:43.616484 +0000] Spawning 2 worker(s) [Thu, 6 Mar 2014 17:55:43.926321 +0000] W#4942 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:43.927454 +0000] W#4943 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:43.929552 +0000] W#4944 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:44.840558 +0000] Spawning 2 worker(s) [Thu, 6 Mar 2014 17:55:45.144466 +0000] W#4949 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:45.145120 +0000] W#4948 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:46.049425 +0000] Spawning 2 worker(s) [Thu, 6 Mar 2014 17:55:46.340310 +0000] W#4952 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:46.340931 +0000] W#4953 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:47.091672 +0000] W#4548 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:47.250309 +0000] M#31248 Spawning worker-replacer for reloaded worker #958 [Thu, 6 Mar 2014 17:55:47.250423 +0000] Spawning 3 worker(s) [Thu, 6 Mar 2014 17:55:47.558718 +0000] W#4956 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:47.559091 +0000] W#4958 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:47.562711 +0000] W#4957 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:47.565347 +0000] W#4959 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:48.462530 +0000] Spawning 3 worker(s) [Thu, 6 Mar 2014 17:55:48.649319 +0000] W#4541 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:48.767455 +0000] W#4965 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:48.768179 +0000] W#4964 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:48.775493 +0000] W#4966 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up.

    things are starting to get crazy here [Thu, 6 Mar 2014 17:55:49.156641 +0000] W#4534 'max-requests' exceed. Graceful shutdown. [Thu, 6 Mar 2014 17:55:49.690276 +0000] M#31248 Spawning worker-replacer for reloaded worker #952 [Thu, 6 Mar 2014 17:55:49.690369 +0000] M#31248 Spawning worker-replacer for reloaded worker #956 [Thu, 6 Mar 2014 17:55:49.690439 +0000] Spawning 3 worker(s) [Thu, 6 Mar 2014 17:55:49.997087 +0000] W#4972 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:49.999313 +0000] W#4976 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:49.999349 +0000] W#4973 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:50.012817 +0000] W#4975 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:50.014513 +0000] W#4974 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:50.777281 +0000] Spawning 4 worker(s) [Thu, 6 Mar 2014 17:55:51.088644 +0000] W#4982 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:51.089061 +0000] W#4984 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:51.090635 +0000] W#4983 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:51.090869 +0000] W#4985 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:51.982448 +0000] Spawning 6 worker(s) [Thu, 6 Mar 2014 17:55:52.295514 +0000] W#4995 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:52.297532 +0000] W#4992 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:52.299258 +0000] W#4994 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:52.301571 +0000] W#4993 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:52.305751 +0000] W#4991 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:52.318936 +0000] W#4990 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:53.203417 +0000] Spawning 6 worker(s) [Thu, 6 Mar 2014 17:55:53.508526 +0000] W#5004 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:53.511501 +0000] W#5007 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:53.515406 +0000] W#5005 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:53.517924 +0000] W#5002 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:53.531455 +0000] W#5006 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:55:53.513904 +0000] W#5003 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up.

    after a few (3) seconds everything winds up out of control [Thu, 6 Mar 2014 17:58:30.776636 +0000] W#6361 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:30.778895 +0000] Spawning 14 worker(s) [Thu, 6 Mar 2014 17:58:30.991519 +0000] W#6360 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:31.268950 +0000] W#6377 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:33.525269 +0000] W#6358 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:34.349243 +0000] W#6402 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:34.361707 +0000] W#6397 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:35.348382 +0000] Spawning 14 worker(s) [Thu, 6 Mar 2014 17:58:35.375137 +0000] W#6428 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:35.378280 +0000] W#6418 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:38.623374 +0000] W#6345 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:38.955308 +0000] W#6333 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:39.396686 +0000] W#6348 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:40.601376 +0000] W#6398 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:42.156584 +0000] Spawning 14 worker(s) [Thu, 6 Mar 2014 17:58:50.666827 +0000] W#6421 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:53.162647 +0000] Spawning 14 worker(s) [Thu, 6 Mar 2014 17:58:54.275637 +0000] W#6408 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:54.789033 +0000] W#6433 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:54.793226 +0000] W#6400 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:54.793834 +0000] W#6434 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:54.809619 +0000] W#6405 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:54.830724 +0000] W#6432 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:56.287545 +0000] W#6431 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:56.380189 +0000] W#6399 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:58.598930 +0000] W#6404 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.157050 +0000] W#6426 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.544690 +0000] W#6401 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.678871 +0000] W#6423 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.678925 +0000] W#6403 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.679469 +0000] W#6396 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.804130 +0000] W#6422 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.836343 +0000] W#6450 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:58:59.848257 +0000] W#6449 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:00.344097 +0000] W#6448 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:00.494307 +0000] W#6453 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:00.518081 +0000] W#6411 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:00.657016 +0000] W#6443 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:00.966787 +0000] W#6437 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:00.994397 +0000] W#6444 \PHPDaemon\Core\Pool:\PHPDaemon\Servers\FastCGI\Pool up. [Thu, 6 Mar 2014 17:59:01.489796 +0000] Spawning 14 worker(s)

    Please help! Thank you!!!

    opened by shaders 9
  • error: Failed to allocate bufferevent for socket

    error: Failed to allocate bufferevent for socket

    phpdaemon is constantly respawning, throwing this error:

    W#28571 crashed by error 'EventBufferEvent::__construct(): Failed to allocate bufferevent for socket' at xxxxx/PHPDaemon/Network/IOStream.php:304
    

    I saw the similar issue in the google groups where one had two libevents installed in the PECL. I have just one installed.

    # pecl list
    INSTALLED PACKAGES, CHANNEL PECL.PHP.NET:
    =========================================
    PACKAGE   VERSION STATE
    eio       1.2.1   stable
    event     1.6.1   stable
    proctitle 0.1.2   alpha
    
    # php -v
    PHP 5.4.9-4ubuntu2.2 (cli) (built: Jul 15 2013 18:23:35)
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    
    # cat /etc/lsb-release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=13.04
    DISTRIB_CODENAME=raring
    DISTRIB_DESCRIPTION="Ubuntu 13.04"
    
    # php -r 'phpinfo();' | egrep '(runkit|eio|event|proctitle)'
    eio
    eio support => enabled
    event
    event support => enabled
    proctitle
    proctitle support => enabled
    runkit
    runkit support => enabled
    runkit.internal_override => On => On
    runkit.superglobal => no value => no value
    

    phpdaemon has been git-clone'd today.

    opened by cidious 9
  • В Chorome 14 сменился протокол WebSocket

    В Chorome 14 сменился протокол WebSocket

    поэтому не получается использовать phpdaemon в новой версии хрома подробности зесь http://blog.chromium.org/2011/08/new-websocket-protocol-secure-and.html

    opened by Danilovonline 9
  • amqp client

    amqp client

    Phpdeamon will be excellent to implement amqp protocol for broker and resolver message.

    any ideas how to start implement async non blocking usage of this protocol ?

    simplicity class over pecl amqp https://github.com/UnionOfRAD/li3_queue/blob/master/extensions/adapter/queue/AMQP.php

    opened by agborkowski 8
  • IPCManager->sendSingleCall

    IPCManager->sendSingleCall

    The sendSingleCall is actually doing a broadcast call. In the function 'op' => 'broadcastCall', should probably be 'op' => 'singleCall'

    Even with that fixed the function is not very helpful. In my test the singleCall just sent the call to the first declared worker, which was busy. When the worker became available it did process the call. If you issue multiple calls they will all be executed sequentially by the first declared worker. In my usage scenario I wanted to issue multiple singleCalls to be exectuted in parallel by the available idle workers.

    Is it possible to modify the sendSingleCall function to find an idle worker instead of just sending the call to the first declared worker?

    opened by dcb 8
  • Ошибка при настроке сервера

    Ошибка при настроке сервера

    При команде sudo phpd start --verbose-tty=1 Появляется ошибка. в чем проблема? PHP Parse error: syntax error, unexpected '.', expecting ')' in /opt/phpdaemon/PHPDaemon/Core/Debug.php on line 69

    opened by trol929 7
  • Часть процессов phpDaemon впадает в бесконечный цикл вызовов epoll_wait и увеличивают использование cpu

    Часть процессов phpDaemon впадает в бесконечный цикл вызовов epoll_wait и увеличивают использование cpu

    Добрый день! Используем phpDaemon для обработки API-запросов. Столкнулись с такой проблемой, что несколько (примерно равно количеству ядер на сервере) процессов phpd через некоторое время (если полностью перезапустить мастер-процесс, то через 10 минут) начинают очень активно делать системные вызовы "epoll_wait" такого вида: [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 766) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 766) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 766) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 764) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 764) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 764) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 764) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 763) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 763) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 763) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 763) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 763) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 762) = 1 [pid 7118] epoll_wait(7, {EPOLLIN, {u32=2, u64=2}}, 32, 762) = 1

    Стрейс статистика по процессу показывает такое: % time | seconds | usecs/call | calls | errors | syscall 98.98 | 0.661405 | 5 | 121343 | | epoll_wait

    lsof процесса выглядит так: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ... php 7118 root 2u a_inode 0,10 0 6487 [eventfd] php 7118 root 3r CHR 1,9 0t0 1033 /dev/urandom php 7118 root 4u a_inode 0,10 0 6487 [eventfd] php 7118 root 5u a_inode 0,10 0 6487 [eventpoll] php 7118 root 6u a_inode 0,10 0 6487 [eventfd] php 7118 root 7u a_inode 0,10 0 6487 [eventpoll] php 7118 root 8w REG 253,0 79811 136834586 /var/log/phpdaemon.log php 7118 root 9u a_inode 0,10 0 6487 [eventfd] ...

    Эти процессы сразу начинают использовать cpu на 100% и cpu на сервере начинает упираться в полку (50% system, 40% nice). При этом кажется, что процессы просто греют воздух и реальной работы не делают. Когда же приходят настоящие запросы, то они успешно выполняются и 5xx ошибок мы не наблюдаем.

    Версия phpDaemon: commit e8d51786e847fe4bf6639cbd152b0c19d6cdb360 Версия php 7.0.33 Версия php-расширения event 2.4.1 libevent2 headers version => 2.0.21-stable

    Конфиг phpDaemon: min-workers 64; max-workers 128; min-spare-workers 32; max-spare-workers 64; start-workers 64; max-idle 120; max-requests 16384;

    phpDaemon запускается через systemd

    На виртуалке - 8 ядер, система - CentOS Linux 7. Также, по наблюдениям, если уменьшить первые 4 опции в конфиге phpDeamon в 2 раза (min-workers, max-workers, min-spare-workers, max-spare-workers), то 100% использования cpu прекращается, но по htop и strace видно, что больные процессы все еще появляются в системе. На более мощном сервере (20 ядер), при таких же настройках phpDaemon, процессы с бесконечным вызовом epoll_wait не появляются.

    Можно ли как-то такое поведение с воркерами починить, чтобы не было бесконечных вызовов epoll_wait?

    opened by lightbliss 6
  • Network\Connection  connect - Closure $beforeConnect not working

    Network\Connection connect - Closure $beforeConnect not working

    $beforeConnect->call($this); not working with $this. Possible solution(not tested): 1: replace $beforeConnect->call($this); with $beforeConnect(); 2: Network\Pool connect: add $beforeConnect->bindTo($conn) after $conn = new $class(null, $this);

    opened by r3l0c 0
  • Phpdaemon benchmark and sending data from php client to web client

    Phpdaemon benchmark and sending data from php client to web client

    Hi all!

    I create WebSocket server on phpdaemon:

    Web client part:

    <script>
        var ws = new WebSocket('ws://site.ll:3333/?user=tester01');
        ws.onmessage = function(evt) { alert(evt.data); };
        ws.onopen = function (event) { ws.send('tester01'); }
    </script>
    

    Worker part:

    namespace PHPDaemon\Applications;
    
    class WSEcho extends \PHPDaemon\Core\AppInstance
    {
        public function onReady()
        {
            $appInstance = $this;
    
            \PHPDaemon\Servers\WebSocket\Pool::getInstance()->addRoute("/", function ($client) use ($appInstance)
            {
                return new WsEchoRoute($client, $appInstance);
            });
        }
    }
    
    class WsEchoRoute extends \PHPDaemon\WebSocket\Route
    {
        public function onHandshake()
        {
            \PHPDaemon\Core\Daemon::log("Connected.");
        }
    
        public function onFrame($data, $type)
        {
            if ($type === "STRING")
            {
                \PHPDaemon\Core\Daemon::log("Receive data «{$data}».");
                $this->client->sendFrame($data);
            }
        }
    
        public function onFinish()
        {
            \PHPDaemon\Core\Daemon::log("Finish connection.");
        }
    }
    

    Config part:

    max-workers     1;
    min-workers     8;
    start-workers   1;
    max-idle        0;
    
    Pool:Servers\WebSocket
    {
            listen 'tcp://0.0.0.0';
            port 3333;
    }
    
    WSEcho
    {
    }
    

    It is work :)

    And I have 2 question:

    1. I receive disconnect each 2 min after connect. Is it normal?

    2. Can I somehow connect from my php code to WebSocket server for sending message Like next:

    $localsocket = 'ws://127.0.0.1:3333';
    $user = 'tester01';
    $message = 'test';
    $instance = stream_socket_client($localsocket);
    fwrite($instance, json_encode(['user' => $user, 'message' => $message])  . "\n");
    

    Thanks!

    opened by Shkarbatov 0
Releases(v1.0-beta)
Owner
Vasily Zorin
Vasily Zorin
Asynchronous & Fault-tolerant PHP Framework for Distributed Applications.

Kraken PHP Framework ~ Release the Kraken! Note: This repository contains the core of the Kraken Framework. If you want to start developing new applic

Kraken 1.1k Dec 27, 2022
REST APIs using Slim framework. Implemented all CRUD operations on the MySql database

PHP REST API using slim framework and CRUD operations ?? Hi there, this is a simple REST API built using the Slim framework. And this is for the folks

Hanoak 2 Jun 1, 2022
Simple WebSocket server implemented in PHP.

Bloatless PHP WebSockets Simple WebSocket server implemented in PHP. Installation Requirements Installation procedure Usage Server Applications Timers

bloatless.org 556 Dec 25, 2022
Hprose asynchronous client & standalone server based on swoole

Hprose for Swoole Introduction Hprose is a High Performance Remote Object Service Engine. It is a modern, lightweight, cross-language, cross-platform,

Hprose 186 Sep 9, 2022
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.

Workerman What is it Workerman is an asynchronous event-driven PHP framework with high performance to build fast and scalable network applications. Wo

walkor 10.2k Dec 31, 2022
A server side alternative implementation of socket.io in PHP based on workerman.

phpsocket.io A server side alternative implementation of socket.io in PHP based on Workerman. Notice Only support socket.io v1.3.0 or greater. This pr

walkor 2.1k Jan 6, 2023
A collapsible side navigation menu built to seamlessly work with Bootstrap framework

yii2-widget-sidenav This widget is a collapsible side navigation menu built to seamlessly work with Bootstrap framework. It is built over Bootstrap st

Kartik Visweswaran 36 Apr 9, 2022
Asynchronous tasks based on ticks.

TickAsync Asynchronous tasks based on ticks. If you like this project gift us a ⭐ . Installation. $ composer require thenlabs/task-loop 2.0.x-dev then

ThenLabs 1 Jan 3, 2022
Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

Framework X Framework X – the simple and fast micro framework for building reactive web applications that run anywhere. Quickstart Documentation Tests

Christian Lück 620 Jan 7, 2023
Multi-process coroutine edition Swoole spider !! Learn about Swoole's network programming and the use of its related APIs

swoole_spider php bin/spider // Just do it !! Cache use Swoole\Table; use App\Table\Cache; $table = new Table(1<<20); // capacity size $table->column

null 3 Apr 22, 2021
AbuseIO is a toolkit to receive, process, correlate and notify about abuse reports received by network operators, typically hosting and access providers.

AbuseIO - Abusemanagement tools AbuseIO is a toolkit to receive, process, correlate and notify end users about abuse reports received by network opera

AbuseIO 189 Dec 6, 2022
With this extension you can share data from your web pages to any social network!

Extension for sharing on social networks With this extension you can share data from your web pages to any social network! Features: SEO support, defa

Yii Maker 50 Oct 15, 2022
🍃Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API

Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API. In short, it's like Tailwind CSS, but for the PHP command-line applications.

Nuno Maduro 1.8k Jan 3, 2023
FrankenPHP is a modern application server for PHP built on top of the Caddy web server

FrankenPHP: Modern App Server for PHP FrankenPHP is a modern application server for PHP built on top of the Caddy web server. FrankenPHP gives superpo

Kévin Dunglas 2.8k Jan 2, 2023
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

Slim Framework 11.5k Jan 4, 2023
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
Mind is the PHP code framework designed for developers. It offers a variety of solutions for creating design patterns, applications and code frameworks.

Mind Mind is the PHP code framework designed for developers. It offers a variety of solutions for creating design patterns, applications and code fram

null 0 Dec 13, 2021
Woski is a fast and simple lightweight PHP Framework for building applications in the realm of the web.

Woski is a simple fast PHP framework for the Realm The Project Installation Clone the repository $ composer create-project clintonnzedimma/woski myApp

Clinton Nzedimma 19 Aug 15, 2022