Пример #1
0
<?php

use React\EventLoop\Factory;
use Rxnet\Event\Event;
use Rxnet\Zmq\RxZmq;
use Rxnet\Zmq\SocketWrapper;
require __DIR__ . "/../../vendor/autoload.php";
$loop = Factory::create();
$zmq = new \Rxnet\Zmq\RxZmq($loop);
$puller = new Puller($zmq);
$puller->handle();
$loop->run();
class Puller
{
    protected $sock = "ipc://zmq.sock";
    /** @var SocketWrapper  */
    protected $puller;
    public function __construct(\Rxnet\Zmq\RxZmq $zmq)
    {
        $this->puller = $zmq->pull();
    }
    public function handle()
    {
        printf("Will bind on %s\n", $this->sock);
        $this->puller->bind($this->sock);
        $this->puller->filter(function (Event $event) {
            return $event->is("/keepalive");
        })->subscribeCallback([$this, 'handleKeepAlive']);
        $this->puller->filter(function (Event $event) {
            return $event->hasPrefix("/request");
        })->subscribeCallback([$this, 'handleRequest']);
Пример #2
0
<?php

// git pull and drupal cr all
$branch = 'branchname';
$puller = new Puller($branch);
$puller->run();
/**
 * Class Puller
 */
class Puller
{
    /**
     * @var string
     */
    private $path_log = '/var/www/projectname/sites/default/files/';
    /**
     * @var string
     */
    private $file_name = 'puller.log';
    /**
     * @var string
     */
    private $log_file = '';
    /**
     * @var array
     */
    private $log = [];
    /**
     * @var string
     */
    private $remote = '';