{"id":252941,"date":"2015-03-12T17:01:03","date_gmt":"2015-03-12T13:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=252941"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=252941","title":{"rendered":"\u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0434\u0435\u043c\u043e\u043d\u0430 \u043d\u0430 PHP \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043a \u043d\u0435\u043c\u0443"},"content":{"rendered":"<p>     \t<img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/575\/7a7\/d3e\/5757a7d3eabe48deb6dc624cd61470a8.jpg\" align=\"left\"\/> \u041d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044f\u0445 \u043c\u044b \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043f\u0440\u043e \u043d\u0430\u0448\u0435 \u043e\u0431\u043b\u0430\u043a\u043e \u0434\u043b\u044f CLI-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 (<a href=\"http:\/\/www.youtube.com\/watch?v=OmN3ltIyV8M\">\u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430<\/a>, <a href=\"http:\/\/www.slideshare.net\/BadooDev\/badoo-hl\">\u0441\u043b\u0430\u0439\u0434\u044b<\/a>). \u041e\u0431\u043b\u0430\u043a\u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 API. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u044d\u0442\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u00ab\u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00bb \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e 100 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0420\u0430\u043d\u0435\u0435 \u043c\u044b \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e. \u041d\u043e, \u043f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0431\u044b \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448\u0438 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 CLI \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0421\u0438, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u043c\u043e\u043d\u044b \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043e\u043a\u043e\u043b\u043e 10%) \u0442\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c, \u043f\u043e \u0441\u0443\u0442\u0438, \u0432\u043f\u0443\u0441\u0442\u0443\u044e: \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u00ab\u044f\u0434\u0440\u0430\u00bb \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438 \u043d\u0430\u0448 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d \u043d\u0430 PHP. \u041c\u044b \u043d\u0430\u0437\u0432\u0430\u043b\u0438 \u0435\u0433\u043e Php<i>rock<\/i>syd (\u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 Phproxyd \u2014 PHP Proxy Daemon, \u0434\u0435\u043c\u043e\u043d\u043e\u043c \u043d\u0430 \u0421\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0434\u043e \u044d\u0442\u043e\u0433\u043e). \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 fork() \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432. \u0422\u0430\u043a\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 Apache, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u00ab\u043c\u0430\u0441\u0442\u0435\u0440\u0435\u00bb \u0438 \u00ab\u0434\u0435\u0442\u0438\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u00ab\u043f\u043b\u044e\u0448\u043a\u0438\u00bb \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c opcode cache \u0432 CLI, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0434\u0435\u0442\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0442\u0443 \u0436\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043e\u0431\u0449\u0435\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e \u0438 \u043c\u0430\u0441\u0442\u0435\u0440-\u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c fork() \u0437\u0430\u0440\u0430\u043d\u0435\u0435 (prefork-\u043c\u043e\u0434\u0435\u043b\u044c), \u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0430 fork() \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u043a\u043e\u043b\u043e 1 \u043c\u0441, \u0447\u0442\u043e \u043d\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u0434 \u0432\u0435\u0441\u044c\u043c\u0430 \u0447\u0430\u0441\u0442\u043e, \u044d\u0442\u043e\u0442 \u0434\u0435\u043c\u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c, \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d \u0432 \u043d\u0435\u0433\u043e, \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u0442\u0430\u0440\u0435\u0442\u044c. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0435\u0441\u0442\u0430\u0440\u0442 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u043b\u0441\u044f \u0431\u044b \u043c\u0430\u0441\u0441\u043e\u0439 \u043e\u0448\u0438\u0431\u043e\u043a \u0432\u0438\u0434\u0430 <i>connection reset by peer<\/i>, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0442\u043a\u0430\u0437\u044b \u0432 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 (\u0434\u0435\u043c\u043e\u043d \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0431\u043b\u0430\u043a\u0430, \u043d\u043e \u0438 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430), \u043c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0441\u0442\u0430\u0440\u0442 \u0434\u0435\u043c\u043e\u043d\u0430 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0443\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0434\u043d\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f <i>graceful reload<\/i> \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u043e\u0432: \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f fork-exec \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0442\u043e\u043c\u043a\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043e\u0442 listen-\u0441\u043e\u043a\u0435\u0442\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u043e\u0432\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0434\u0435\u043c\u043e\u043d\u0430, \u0430 \u0441\u0442\u0430\u0440\u044b\u0435 \u00ab\u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u00bb \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <i>graceful reload<\/i>: \u0441\u0442\u0430\u0440\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0434\u0435\u043c\u043e\u043d\u0430, \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u043d\u0430\u0447\u0435 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<h3>\u0422\u0435\u043e\u0440\u0438\u044f<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0434\u0443\u043c\u0430\u0435\u043c: \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c? \u0418 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043a\u0430\u043a \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0438\u0447\u044c?<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0435\u043c\u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0434 Linux, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f POSIX-\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u043c, \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\u0412\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0441\u043e\u043a\u0435\u0442\u044b \u2014 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u0430, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043d\u043e\u043c\u0435\u0440\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434, \u0432\u044b\u0432\u043e\u0434 \u0438 \u043f\u043e\u0442\u043e\u043a \u043e\u0448\u0438\u0431\u043e\u043a \u0438\u043c\u0435\u044e\u0442 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b 0, 1 \u0438 2 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/li>\n<li>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c, \u0441\u043e\u043a\u0435\u0442\u043e\u043c \u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u043c (pipe) \u043d\u0435\u0442 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u0441\u043e\u043a\u0435\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 read\/write, \u0442\u0430\u043a \u0438 sendto\/recvfrom).<\/li>\n<li>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 fork() \u0432\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f\/\u0437\u0430\u043f\u0438\u0441\u0438 (\u0432 \u0444\u0430\u0439\u043b\u0430\u0445).<\/li>\n<li>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 execve() \u0432\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f, \u043f\u0440\u0438\u0447\u0435\u043c \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 \u043a \u0441\u0432\u043e\u0438\u043c \u0434\u0435\u0442\u044f\u043c.<\/li>\n<li>\u0421\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \/dev\/fd, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 Linux \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043c\u043b\u0438\u043d\u043a\u043e\u043c \u043d\u0430 \/proc\/self\/fd.<\/li>\n<\/ol>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c\u0430, \u043f\u0440\u0438\u0447\u0435\u043c \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u0418\u0442\u0430\u043a, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<h3>\u041f\u0430\u0442\u0447\u0438 \u043a PHP<\/h3>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043d\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0443: \u0432 PHP \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (streams) \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043f\u043e \u043d\u043e\u043c\u0435\u0440\u0443 (\u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430, \u0447\u0442\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0430 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043e\u0447\u0435\u043d\u044c \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u043c \u0437\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u0442\u0435\u0447\u0435\u043a \u043f\u0440\u0438 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0435 \u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432).<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0432\u043d\u0435\u0441\u0435\u043c \u043f\u0430\u0440\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0430\u0442\u0447\u0435\u0439 \u0432 \u043a\u043e\u0434 PHP, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c fd \u0443 \u043f\u043e\u0442\u043e\u043a\u0430 (stream) \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b fopen(php:\/\/fd\/&lt;num&gt;) \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u043a \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044e \u043a\u043e\u043f\u0438\u0438 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 (\u0432\u0442\u043e\u0440\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c PHP, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u00ab\u0430\u0434\u0440\u0435\u0441\u00bb, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, php:\/\/fdraw\/&lt;num&gt;):<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043f\u0430\u0442\u0447\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">diff --git a\/ext\/standard\/php_fopen_wrapper.c b\/ext\/standard\/php_fopen_wrapper.c index f8d7bda..fee964c 100644 --- a\/ext\/standard\/php_fopen_wrapper.c +++ b\/ext\/standard\/php_fopen_wrapper.c @@ -24,6 +24,7 @@ #if HAVE_UNISTD_H #include &lt;unistd.h&gt; #endif +#include &lt;fcntl.h&gt; #include &quot;php.h&quot; #include &quot;php_globals.h&quot; @@ -296,11 +297,11 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch \t\t\t\t&quot;The file descriptors must be non-negative numbers smaller than %d&quot;, dtablesize); \t\t\treturn NULL; \t\t} -\t\t -\t\tfd = dup(fildes_ori); -\t\tif (fd == -1) { + +\t\tfd = fildes_ori; +\t\tif (fcntl(fildes_ori, F_GETFD) == -1) { \t\t\tphp_stream_wrapper_log_error(wrapper, options TSRMLS_CC, -\t\t\t\t&quot;Error duping file descriptor %ld; possibly it doesn't exist: &quot; +\t\t\t\t&quot;File descriptor %ld invalid: &quot; \t\t\t\t&quot;[%d]: %s&quot;, fildes_ori, errno, strerror(errno)); \t\t\treturn NULL; \t\t} diff --git a\/ext\/standard\/streamsfuncs.c b\/ext\/standard\/streamsfuncs.c index 0610ecf..14fd3b0 100644 --- a\/ext\/standard\/streamsfuncs.c +++ b\/ext\/standard\/streamsfuncs.c @@ -24,6 +24,7 @@ #include &quot;ext\/standard\/flock_compat.h&quot; #include &quot;ext\/standard\/file.h&quot; #include &quot;ext\/standard\/php_filestat.h&quot; +#include &quot;ext\/standard\/php_fopen_wrappers.h&quot; #include &quot;php_open_temporary_file.h&quot; #include &quot;ext\/standard\/basic_functions.h&quot; #include &quot;php_ini.h&quot; @@ -484,6 +485,7 @@ PHP_FUNCTION(stream_get_meta_data) \tzval *arg1; \tphp_stream *stream; \tzval *newval; +\tint tmp_fd; \tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &quot;r&quot;, &arg1) == FAILURE) { \t\treturn; @@ -502,6 +504,9 @@ PHP_FUNCTION(stream_get_meta_data) \t\tadd_assoc_string(return_value, &quot;wrapper_type&quot;, (char *)stream-&gt;wrapper-&gt;wops-&gt;label, 1); \t} \tadd_assoc_string(return_value, &quot;stream_type&quot;, (char *)stream-&gt;ops-&gt;label, 1); +\tif (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&tmp_fd, 1) && tmp_fd != -1) { +\t\tadd_assoc_long(return_value, &quot;fd&quot;, tmp_fd); +\t} \tadd_assoc_string(return_value, &quot;mode&quot;, stream-&gt;mode, 1); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u043b\u0435 fd \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 stream_get_meta_data(), \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f zlib-\u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043f\u043e\u043b\u0435 fd \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c). \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438 \u0432\u044b\u0437\u043e\u0432 dup() \u043e\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439 \u043f\u043e\u0434 Windows, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u044b\u0437\u043e\u0432 fcntl() \u2014 \u044d\u0442\u043e POSIX-specific, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0430\u0442\u0447 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0442\u043a\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u0435 \u041e\u0421.<\/p>\n<h3>\u0414\u0435\u043c\u043e\u043d \u0431\u0435\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0442\u0432\u0435\u0442. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0448\u0435\u043b \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.<\/p>\n<p>  \u0414\u0435\u043c\u043e\u043d \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0440\u0442 31337. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:  <\/p>\n<blockquote>\n<pre><code>$ telnet localhost 31337 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. {&quot;hash&quot;:1} # \u0432\u0432\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &quot;Request had 1 keys&quot; {&quot;hash&quot;:1,&quot;cnt&quot;:2} # \u0432\u0432\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &quot;Request had 2 keys&quot; <\/code><\/pre>\n<p>  <\/p><\/blockquote>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c stream_socket_server() \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0447\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u043f\u043e\u0440\u0442, \u0438 stream_select() \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u0447\u0442\u0435\u043d\u0438\u044e\/\u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (Simple.php)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php class Simple {    const PORT = 31337;    const SERVER_KEY = 'SERVER';     \/** @var resource[] (client_id =&gt; stream) *\/    private $streams = [];    \/** @var string[] (client_id =&gt; read buffer) *\/    private $read_buf = [];     \/** @var string[] (client_id =&gt; write buffer) *\/    private $write_buf = [];    \/** @var resource[] (client_id =&gt; stream from which to read) *\/    private $read = [];    \/** @var resource[] (client_id =&gt; stream where to write) *\/    private $write = [];     \/** @var int Total connection count *\/    private $conn_count = 0;     public function run()    {        $this-&gt;listen();        echo &quot;Entering main loop\\n&quot;;        $this-&gt;mainLoop();    }     protected function listen()    {        $port = self::PORT;        $ip_port = &quot;0.0.0.0:$port&quot;;        $address = &quot;tcp:\/\/$ip_port&quot;;         $server = stream_socket_server($address, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN);        if (!$server) {            fwrite(STDERR, &quot;stream_socket_server failed: $errno $errstr\\n&quot;);            exit(1);        }         $this-&gt;read[self::SERVER_KEY] = $server;        echo &quot;Listening on $address\\n&quot;;    }     public function response($stream_id, $response)    {        $json_resp = json_encode($response);        echo &quot;stream$stream_id &quot; . $json_resp . &quot;\\n&quot;;        $this-&gt;write($stream_id, $json_resp . &quot;\\n&quot;);    }     public function write($stream_id, $buf)    {        $this-&gt;write_buf[$stream_id] .= $buf;         if (!isset($this-&gt;write[$stream_id])) {            $this-&gt;write[$stream_id] = $this-&gt;streams[$stream_id];        }    }     public function accept($server)    {        echo &quot;Accepting new connection\\n&quot;;         $client = stream_socket_accept($server, 1, $peername);        $stream_id = ($this-&gt;conn_count++);        if (!$client) {            fwrite(STDERR, &quot;Accept failed\\n&quot;);            return;        }         stream_set_read_buffer($client, 0);        stream_set_write_buffer($client, 0);        stream_set_blocking($client, 0);        stream_set_timeout($client, 1);         $this-&gt;read_buf[$stream_id] = '';        $this-&gt;write_buf[$stream_id] = '';        $this-&gt;read[$stream_id] = $this-&gt;streams[$stream_id] = $client;         echo &quot;Connected stream$stream_id: $peername\\n&quot;;    }     private function disconnect($stream_id)    {        echo &quot;Disconnect stream$stream_id\\n&quot;;        unset($this-&gt;read_buf[$stream_id], $this-&gt;write_buf[$stream_id]);        unset($this-&gt;streams[$stream_id]);        unset($this-&gt;write[$stream_id], $this-&gt;read[$stream_id]);    }     private function handleRead($stream_id)    {        $buf = fread($this-&gt;streams[$stream_id], 8192);        if ($buf === false || $buf === '') {            echo &quot;got EOF from stream$stream_id\\n&quot;;            if (empty($this-&gt;write_buf[$stream_id])) {                $this-&gt;disconnect($stream_id);            } else {                unset($this-&gt;read[$stream_id]);            }            return;        }         $this-&gt;read_buf[$stream_id] .= $buf;        $this-&gt;processJSONRequests($stream_id);    }     private function processJSONRequests($stream_id)    {        if (!strpos($this-&gt;read_buf[$stream_id], &quot;\\n&quot;)) return;        $requests = explode(&quot;\\n&quot;, $this-&gt;read_buf[$stream_id]);        $this-&gt;read_buf[$stream_id] = array_pop($requests);         foreach ($requests as $req) {            $res = json_decode(rtrim($req), true);             if ($res !== false) {                $this-&gt;response($stream_id, &quot;Request had &quot; . count($res) . &quot; keys&quot;);            } else {                $this-&gt;response($stream_id, &quot;Invalid JSON&quot;);            }        }    }     private function handleWrite($stream_id)    {        if (!isset($this-&gt;write_buf[$stream_id])) {            return;        }         $wrote = fwrite($this-&gt;streams[$stream_id], substr($this-&gt;write_buf[$stream_id], 0, 65536));        if ($wrote === false) {            fwrite(STDERR, &quot;write failed into stream #$stream_id\\n&quot;);            $this-&gt;disconnect($stream_id);            return;        }         if ($wrote === strlen($this-&gt;write_buf[$stream_id])) {            $this-&gt;write_buf[$stream_id] = '';            unset($this-&gt;write[$stream_id]);            if (empty($this-&gt;read[$stream_id])) {                $this-&gt;disconnect($stream_id);            }        } else {            $this-&gt;write_buf[$stream_id] = substr($this-&gt;write_buf[$stream_id], $wrote);        }    }     public function mainLoop()    {        while (true) {            $read = $this-&gt;read;            $write = $this-&gt;write;            $except = null;             echo &quot;Selecting for &quot; . count($read) . &quot; reads, &quot; . count($write) . &quot; writes\\n&quot;;            $n = stream_select($read, $write, $except, NULL);             if (!$n) {                fwrite(STDERR, &quot;Could not stream_select()\\n&quot;);            }             if (count($read)) {                echo &quot;Can read from &quot; . count($read) . &quot; streams\\n&quot;;            }             if (count($write)) {                echo &quot;Can write to &quot; . count($write) . &quot; streams\\n&quot;;            }             if (isset($read[self::SERVER_KEY])) {                $this-&gt;accept($read[self::SERVER_KEY]);                unset($read[self::SERVER_KEY]);            }             foreach ($read as $stream_id =&gt; $_) {                $this-&gt;handleRead($stream_id);            }             foreach ($write as $stream_id =&gt; $_) {                $this-&gt;handleWrite($stream_id);            }        }    } }  $instance = new Simple(); $instance-&gt;run(); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439, \u043e\u0434\u043d\u0430\u043a\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0434\u0435\u0442\u0430\u043b\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438: \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0432\u0441\u0435 \u0431\u0443\u0444\u0435\u0440\u044b \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u043e\u0439 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u0432 \u0442\u043e\u043c \u0436\u0435 \u043c\u0435\u0441\u0442\u0435, \u0433\u0434\u0435 \u0447\u0438\u0442\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c restart, \u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0434\u0435\u043b\u043e \u043d\u0435 \u0434\u043e\u0439\u0434\u0435\u0442. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 stream_select() \u043e\u0442 \u0442\u0435\u0445 \u0436\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0432\u0435\u0440\u043d\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u043c \u043d\u0438 \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0435\u0441\u043b\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u043c \u0440\u0435\u0441\u0442\u0430\u0440\u0442 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b (\u043a\u0440\u043e\u043c\u0435 \u0441\u043b\u0443\u0447\u0430\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u044e\u0442 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u0430\u043d\u0434 \u0432 \u0442\u043e \u0436\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u0438 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0431\u0443\u0434\u0435\u0442 restart).<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0434\u0435\u043c\u043e\u043d\u0430?<\/p>\n<h3>\u0414\u0435\u043c\u043e\u043d \u0441 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439<\/h3>\n<p>  \u041d\u0430\u0448 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0443\u043c\u0435\u043b \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u0435 \u0436\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u0435\u043c\u043e\u043d, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0448\u043b\u0430 \u0440\u0435\u0447\u044c \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 (\u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0435\u043c\u043e\u043d\u0443 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u00ab\u0438\u043c\u044f_\u043a\u043e\u043c\u0430\u043d\u0434\u044b[ JSON-\u0434\u0430\u043d\u043d\u044b\u0435]\u00bb, \u043e\u0442\u0432\u0435\u0442 \u0432 \u0432\u0438\u0434\u0435 JSON):  <\/p>\n<blockquote>\n<pre><code>$ telnet localhost 31337 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. # \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c \u0434\u0435\u043c\u043e\u043d \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f restart # \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u0434\u0435\u043c\u043e\u043d &quot;Restarted successfully&quot; # \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 run {&quot;hash&quot;:1,&quot;params&quot;:[1,2,3],&quot;class&quot;:&quot;TestClass1&quot;} # \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e {&quot;error_text&quot;:&quot;OK&quot;} # \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0438\u043c \u0434\u0435\u043c\u043e\u043d \u0435\u0449\u0435 \u0440\u0430\u0437 (\u0435\u0433\u043e child TestClass1 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442) restart &quot;Restarted successfully&quot; # \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u0437\u0430\u0434\u0430\u043d\u0438\u044f: \u0432\u0441\u0435 \u0435\u0449\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 check {&quot;hash&quot;:1} {&quot;error_text&quot;:&quot;Still running&quot;} # \u043f\u043e\u0434\u043e\u0436\u0434\u0435\u043c 5 \u0441\u0435\u043a\u0443\u043d\u0434 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0435\u0449\u0435 \u0440\u0430\u0437: \u043a\u043b\u0430\u0441\u0441 TestClass1 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e check {&quot;hash&quot;:1} {&quot;retcode&quot;:0} # \u0434\u0435\u043c\u043e\u043d \u043f\u043e\u043c\u043d\u0438\u0442 \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c free check {&quot;hash&quot;:1} {&quot;retcode&quot;:0} free {&quot;hash&quot;:1} {&quot;error_text&quot;:&quot;OK&quot;} restart &quot;Restarted successfully&quot; # \u044f \u043e\u0431\u043d\u043e\u0432\u0438\u043b \u043a\u043e\u0434, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0437 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 restart restart {&quot;error_text&quot;:&quot;Restarted successfully&quot;} bye Connection closed by foreign host. <\/code><\/pre>\n<p>  <\/p><\/blockquote>\n<p>  \u0418\u0434\u0435\u044f \u0434\u043b\u044f \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u043e \u0432\u0441\u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439, \u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 restart-\u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"php\">echo &quot;Creating restart file...\\n&quot;;  if (!$res = $this-&gt;getFdRestartData()) {    fwrite(STDERR, &quot;Could not get restart FD data, exiting, graceful restart is not supported\\n&quot;);    exit(0); }  \/* Close all extra file descriptors that we do not know of, including opendir() descriptor :) *\/ $dh = opendir(&quot;\/proc\/self\/fd&quot;); $fds = []; while (false !== ($file = readdir($dh))) {    if ($file[0] === '.') continue;    $fds[] = $file; }  foreach ($fds as $fd) {    if (!isset($this-&gt;known_fds[$fd])) {        fclose(fopen(&quot;php:\/\/fd\/&quot; . $fd, 'r+'));    } }  $contents = serialize($res);  if (file_put_contents(self::RESTART_DIR . self::RESTART_FILENAME, $contents) !== strlen($contents)) {    fwrite(STDERR, &quot;Could not fully write restart file\\n&quot;);    unlink(self::RESTART_DIR . self::RESTART_FILENAME); } <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0444\u0443\u043d\u043a\u0446\u0438\u044f getFdRestartData()) \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"php\">$res = [];  foreach (self::$restart_fd_resources as $prop) {    $res[$prop] = [];    foreach ($this-&gt;$prop as $k =&gt; $v) {        $meta = stream_get_meta_data($v);        if (!isset($meta['fd'])) {            fwrite(STDERR, &quot;No fd in stream metadata for resource $v (key $k in $prop), got &quot; . var_export($meta, true) . &quot;\\n&quot;);            return false;        }        $res[$prop][$k] = $meta['fd'];        $this-&gt;known_fds[$meta['fd']] = true;    } }  foreach (self::$restart_fd_props as $prop) {    $res[$prop] = $this-&gt;$prop; }  return $res; <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 2 \u0432\u0438\u0434\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432:  <\/p>\n<ol>\n<li>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c\u0438: $restart_fd_resources = [&#8216;read&#8217;, &#8216;write&#8217;, &#8216;streams&#8217;].<\/li>\n<li>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u044b \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u00ab\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u00bb \u0432 \u0441\u044b\u0440\u043e\u043c \u0432\u0438\u0434\u0435: $restart_fd_props = [&#8216;read_buf&#8217;, &#8216;write_buf&#8217;, &#8216;conn_count&#8217;].<\/li>\n<\/ol>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0432\u0441\u0435 fd, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0435 \u0432 restart-\u0444\u0430\u0439\u043b\u0435, \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c), \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u043d\u0430\u0447\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0443\u0442\u0435\u0447\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e :). \u041a\u043e\u0434 \u0434\u0432\u0443\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 restart-\u0444\u0430\u0439\u043b\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430\u0445) \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043d\u0438\u0436\u0435:<\/p>\n<p>  <b>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0430\u0439\u043b\u0430:<\/b><\/p>\n<pre><code class=\"php\">if (!file_exists(self::RESTART_DIR . self::RESTART_FILENAME)) {    return; }  echo &quot;Restart file found, trying to adopt it\\n&quot;;  $contents = file_get_contents(self::RESTART_DIR . self::RESTART_FILENAME); unlink(self::RESTART_DIR . self::RESTART_FILENAME);  if ($contents === false) {    fwrite(STDERR, &quot;Could not read restart file\\n&quot;);    return; }  $res = unserialize($contents); if (!$res) {    fwrite(STDERR, &quot;Could not unserialize restart file contents&quot;);    return; }  foreach (self::$restart_props as $prop) {    if (!array_key_exists($prop, $res)) {        fwrite(STDERR, &quot;No property $prop in restart file\\n&quot;);        continue;    }    $this-&gt;$prop = $res[$prop]; }  $this-&gt;loadFdRestartData($res); <\/code><\/pre>\n<p>  <b>\u0424\u0443\u043d\u043a\u0446\u0438\u044f loadFdRestartData() \u043f\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e:<\/b><\/p>\n<pre><code class=\"php\">$fd_resources = [];  foreach (self::$restart_fd_resources as $prop) {    if (!isset($res[$prop])) {        fwrite(STDERR, &quot;Property '$prop' is not present in restart fd resources\\n&quot;);        continue;    }     $pp = [];    foreach ($res[$prop] as $k =&gt; $v) {        if (isset($fd_resources[$v])) {            $pp[$k] = $fd_resources[$v];        } else {            $fp = fopen(&quot;php:\/\/fd\/&quot; . $v, 'r+');            if (!$fp) {                fwrite(STDERR, &quot;Failed to open fd = $v, exiting\\n&quot;);                exit(1);            }             stream_set_read_buffer($fp, 0);            stream_set_write_buffer($fp, 0);            stream_set_blocking($fp, 0);            stream_set_timeout($fp, self::CONN_TIMEOUT);             $fd_resources[$v] = $fp;            $pp[$k] = $fp;        }    }    $this-&gt;$prop = $pp; }  foreach (self::$restart_fd_props as $prop) {    if (!isset($res[$prop])) {        fwrite(STDERR, &quot;Property '$prop' is not present in restart fd properties\\n&quot;);        continue;    }     $this-&gt;$prop = $res[$prop]; } <\/code><\/pre>\n<p>  \u041c\u044b \u0437\u0430\u043d\u043e\u0432\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f read_buffer \u0438 write_buffer \u0434\u043b\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u043e\u0432 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u044b. \u041a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 PHP \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442 accept() \u043d\u0430 \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c\/\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043d\u0438\u0445 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043e\u043a\u0435\u0442\u044b.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u0438 \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u044e \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043f\u043e\u043b\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043c\u043e\u043d\u0430 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0430 \u043d\u0430 github-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u043d\u0438\u0436\u0435.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0418\u0442\u0430\u043a, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043c\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e JSON-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 \u0438 \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u0441\u043e \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u0435\u043c \u0437\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c <i>fork() \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/i>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 opcode cache \u0432 CLI. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0434\u0435\u043c\u043e\u043d \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043c\u043e\u043d\u0430 (\u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442, \u0432 \u0432\u0438\u0434\u0435 \u00ab\u0445\u043e\u0442\u0444\u0438\u043a\u0441\u043e\u0432\u00bb).<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 execve(), \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043c\u043a\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u043a \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044e (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 PID \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0438 execve() \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f). \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0443\u0436\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u0445. \u0412\u0441\u0435 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0431\u0443\u0444\u0435\u0440\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0442\u044f\u0445 \u0438 \u043e\u0431 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 restart-\u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u0434\u0435\u043c\u043e\u043d\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c event loop.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 GitHub \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443: <a href=\"https:\/\/github.com\/badoo\/habr\/tree\/master\/phprocksyd\">github.com\/badoo\/habr\/tree\/master\/phprocksyd<\/a><\/p>\n<p>  \u0412\u043e\u043f\u0440\u043e\u0441\u044b, \u043f\u043e\u0436\u0435\u043b\u0430\u043d\u0438\u044f, \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u0421 \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0435\u043c,<br \/>  <i>\u042e\u0440\u0438\u0439 <a href=\"http:\/\/habrahabr.ru\/users\/yourock\/\" class=\"user_link\">youROCK<\/a> \u041d\u0430\u0441\u0440\u0435\u0442\u0434\u0438\u043d\u043e\u0432<br \/>  Lead PHP developer<br \/>  Badoo<\/i>      \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/252809\/\"> http:\/\/habrahabr.ru\/post\/252809\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/575\/7a7\/d3e\/5757a7d3eabe48deb6dc624cd61470a8.jpg\" align=\"left\"\/> \u041d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044f\u0445 \u043c\u044b \u043d\u0435\u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043f\u0440\u043e \u043d\u0430\u0448\u0435 \u043e\u0431\u043b\u0430\u043a\u043e \u0434\u043b\u044f CLI-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 (<a href=\"http:\/\/www.youtube.com\/watch?v=OmN3ltIyV8M\">\u0432\u0438\u0434\u0435\u043e\u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430<\/a>, <a href=\"http:\/\/www.slideshare.net\/BadooDev\/badoo-hl\">\u0441\u043b\u0430\u0439\u0434\u044b<\/a>). \u041e\u0431\u043b\u0430\u043a\u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 API. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u044d\u0442\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u00ab\u0440\u0430\u0437\u043c\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u00bb \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e 100 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c. \u0420\u0430\u043d\u0435\u0435 \u043c\u044b \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0437\u0430\u0434\u0430\u043d\u0438\u0439 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e. \u041d\u043e, \u043f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0431\u044b \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448\u0438 PHP-\u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 CLI \u0438 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043e\u043d \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0421\u0438, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u043c\u043e\u043d\u044b \u0432 \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043e\u043a\u043e\u043b\u043e 10%) \u0442\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c, \u043f\u043e \u0441\u0443\u0442\u0438, \u0432\u043f\u0443\u0441\u0442\u0443\u044e: \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u00ab\u044f\u0434\u0440\u0430\u00bb \u043d\u0430\u0448\u0435\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u0438 \u043d\u0430\u0448 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u043c\u043e\u043d \u043d\u0430 PHP. \u041c\u044b \u043d\u0430\u0437\u0432\u0430\u043b\u0438 \u0435\u0433\u043e Php<i>rock<\/i>syd (\u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 Phproxyd \u2014 PHP Proxy Daemon, \u0434\u0435\u043c\u043e\u043d\u043e\u043c \u043d\u0430 \u0421\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b \u0434\u043e \u044d\u0442\u043e\u0433\u043e). \u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 fork() \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432. \u0422\u0430\u043a\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 Apache, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u00ab\u043c\u0430\u0441\u0442\u0435\u0440\u0435\u00bb \u0438 \u00ab\u0434\u0435\u0442\u0438\u00bb \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u00ab\u043f\u043b\u044e\u0448\u043a\u0438\u00bb \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c opcode cache \u0432 CLI, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0434\u0435\u0442\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0442\u0443 \u0436\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043e\u0431\u0449\u0435\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e \u0438 \u043c\u0430\u0441\u0442\u0435\u0440-\u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0427\u0442\u043e\u0431\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c fork() \u0437\u0430\u0440\u0430\u043d\u0435\u0435 (prefork-\u043c\u043e\u0434\u0435\u043b\u044c), \u043d\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0430 fork() \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u043a\u043e\u043b\u043e 1 \u043c\u0441, \u0447\u0442\u043e \u043d\u0430\u0441 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-252941","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=252941"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252941\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=252941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=252941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=252941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}