-
PHP redis 연동개발/php 2018. 11. 9. 17:40
설치
yum install redis systemctl start redis cd ./workspace composer require chrisboulton/php-resque
Push.php
\Resque::setBackend('localhost:6379'); $args = [ 'idx' => 1, ]; Resque::enqueue('queue-name', Jobs::class, $args);
Jobs.php
<?php class Jobs { public function perform() { $idx = $this->args['idx']; //Push.php 에서 보낸 idx //.. code } }
Push.php 를 실행시켜 설치한 서버 Redis 에 데이터를 쌓게 되고 Jobs 를 호출함으로써 큐에 쌓여진데로 순차적으로 실행하게된다.
redis-cli
$ redis-cli 127.0.0.1:6379> llen resque:queue:queue-name 3
이제 worker (큐 순차처리) 를 사용하여야 하는데 foreverd 데몬을 활용하여 실행시켜보자
실행시키는 bin/resque file 은 composer 설치 디렉토리에 포함되어있다.
forever 추가
VERBOSE=1 QUEUE=queue-name forever -l /home/tmp/logs.log -a start -c "sh " bin/resque
VERBOSE = 기본디버그 추가, QUEUE = 큐이름
redis-cli 큐 실행이후
$ redis-cli 127.0.0.1:6379> llen resque:queue:queue-name 0
'개발 > php' 카테고리의 다른 글
PHP mkdir 권한 문제(umask) (0) 2018.11.09 PHP 대용량 엑셀다운로드 (1) 2018.11.09 php 에서 한글포함 여부를 체크해보자 (0) 2018.11.09 Php open_tag 관련 (0) 2016.08.13 트레이트 (0) 2016.08.07