2010-05-12 2 views
1

beanstalkd와 함께 작업을 예약 할 수 없습니다 (소스에서 컴파일 된에서라도에 로컬 및 냠가 설치된 CentOS는 서버)I가 실행 beanstalkd 얻고 몇 가지 테스트를 수행하는 두 개의 서로 다른 서버에 시도

I 하나

sudo beanstalkd -d -p 11300 

또는

sudo beanstalkd -p 11300 & 

와 나는 다음의 PHP lib 디렉토리를 사용하여 시도 실행하는 서버를 얻고 그것은 단지 동결 할 수 있습니다. 직접 연결 : I이 (가) PHP 테스트 스크립트를 모방하기 위해 다음을 수행

telnet localhost 11300 

:

use foo 
USING foo 
put 0 0 120 5 
hello 
INSERTED 1 
reserve-with-timeout 0 
TIMED_OUT 

난 그냥 그것은 무기한 붙어

reserve 

실행하는 경우.

PHP 코드는

/** 
    * BeanStalk 0.10 - Example code 
    * 
    * This is a quick example to get you started using the client. 
    */ 

    require(dirname(__FILE__).'/../src/BeanStalk.class.php'); 

    /** 
    * Connect to the beanstalkd server(s) 
    * 
    * Option array: 
    * 
    *  array(
    *   'servers'    => array('ip:port'[, 'ip:port'[, ...]]), 
    *   'select'    => 'random wait', 
    *   'connection_timeout' => 0.5, 
    *   'peek_usleep'   => 2500, 
    *   'connection_retries' => 3, 
    *   'auto_unyaml'   => true 
    *  ); 
    * 
    * select -> this tells the client what type of blocking to use when selecting from 
    * different servers. There are currently four choices: 
    * 
    * random wait:  pick a random server from the list and wait for a job 
    * 
    * sequential wait: pick the next server in the list and wait for a job 
    * 
    * random peek:  in a loop, pick a random server and peek-ready(), looking for a job 
    *      until a server is found that has something available. 
    * 
    * sequential peek: in a loop, pick the next server and peek-ready() ... etc. 
    * 
    * the *peek modes have a companion setting, peek_usleep, which tells the client how long 
    * to usleep() for between peeks to servers. 
    * 
    * auto_unyaml -> if true, this causes the client to assume the presence of the syck yaml 
    * parser, and attempts to 'unyamlize' yaml output for you before returning it. 
    */ 
echo "opening\n"; 
    $beanstalk = BeanStalk::open(array(
     'servers'  => array('127.0.0.1:11300'), 
     'select'  => 'random peek' 
    )); 

echo "switching tube\n"; 

    // As in the protocol doc. 
    $beanstalk->use_tube('foo'); 

echo "putting job\n"; 

    // As in the protocol doc. 
    $beanstalk->put(0, 0, 120, 'say hello world');  // Add a job to the queue with highest priority, 
                 // no delay, 120 seconds TTR, with the contents 
                 // 'say hello world'. 

                 // NOTE: the put() method here supports a final optional 
                 // argument, a tube name. If supplied, the server will 
                 // first switch to that tube, write the job, then switch 
                 // back to the old tube again. 

echo "trying to reserve\n"; 

    // As in the protocol doc. 
    $job = $beanstalk->reserve();      // Assuming there was nothing in the queue before 
                 // we started, this will give us our 'hello world' 
                 // job back. 

echo "about to output\n";  

    // This is a BeanQueueJob object. 
    echo $job->get();         // Output: 'say hello world' 

    Beanstalk::delete($job);       // Delete the job. 

하고 그냥 "예약하려고"에 정지.

http://sourceforge.net/projects/beanstalk/

어떤 아이디어 :에서 원본 코드? 미리 감사드립니다.

+0

문제가있는 PHP 코드를 추가 할 수 있습니까? 또한 데몬의 버전 ('beanstalkd -v'). 항상 데몬으로 실행하지 않아도됩니다. 터미널 창에서 전방에 행복하게 사이트를 게시합니다. –

+0

버전 1.4.4의 경우 위의 PHP 코드를 추가했습니다. 팁을 주셔서 감사 드리며 -d로 실행하지 마십시오. 동일한 문제가 적용되지만 무한 루프를 죽이는 시간을 절약 할 수 있습니다. –

+0

위의 텔넷 명령을 사용할 때 list-tubes 명령이 "foo"목록을 표시하지만 새 튜브를 사용하지 않을 때 예약 할 수 있습니다. 그래서 설정이나 설정에서 별도의 튜브가 작동하는 것을 막을 수 있습니다. –

답변

7

기본값 이외의 튜브를 사용하려면 해당 튜브에 "시계"를 추가해야합니다. 예를 들어 : 이것은이 "사용"것을 의미하는 것으로 보인다 문서, 너무 명확하지 않다

use foo 
USING foo 
put 0 0 120 5 
hello 
INSERTED 1 
reserve-with-timeout 5 
TIMED_OUT 
list-tubes 
OK 20 
--- 
- default 
- foo 

watch foo 
WATCHING 2 
reserve-with-timeout 5 
RESERVED 1 5 
hello 

명령은 자동으로 예약이 튜브를 사용하여 명령이 - 자동으로 넣어 튜브 것을 사용하는 것처럼.

희망이 있으면 다른 콩팥 새내기가 도움이됩니다.

+0

[beanstalkc 튜토리얼] (http://github.com/earl/beanstalkc/blob/master/TUTORIAL) (특히 [line 138ff] (http://github.com/)/beanstalkc/blob/master/튜토리얼 # L138)). 이 튜토리얼은 Python 클라이언트 라이브러리 용으로 작성되었지만 대부분의 beanstalkd 측면을 다루며 다른 언어/라이브러리 사용자에게도 유용 할 수 있습니다. – earl

+0

Brilliant, 링크 백의 덕분입니다. 다른 언어/라이브러리로 쉽게 소개 할 수 있습니다. –

+1

키워드를 사용하면 튜브에 데이터를 넣는 것이고, watch 키워드는 하나를 검색하는 것입니다. 대답은 좋다, 문제는 저자가 쓰지 않는 튜브에 쓰는 문제이다. – asdmin

-1

예약시 차단되도록 설계되어있어 작업을 기다리고 있습니다. 다른 터미널에서 튜브에 일자리를 넣으십시오 - 예약 명령은 새 작업과 함께 반환됩니다.

+0

첫째, OP는 reserve-with-timeout을 사용하고있다; 이것은 막히면 안된다. 둘째, 그들은 먼저 튜브에 일자리를 부여한 다음 작업을 예약하므로 다른 모든 것이 좋으면 (즉 튜브에 다른 관찰자가없는 경우) 작업을 즉시 사용할 수 있어야합니다. –

3

https://raw.github.com/kr/beanstalkd/master/doc/protocol.txt

이 문서는 더 분명하다.

"사용"명령은 생산자를위한 것입니다. 후속 put 명령은이 명령으로 지정된 튜브를 에 넣습니다. 사용 명령이 없으면 작업 이 "default"라는 튜브에 입력됩니다.

"watch"명령은 현재 연결에 대한 감시 목록에 명명 된 튜브를 추가합니다. 예약 명령은 감시 목록에있는 튜브에서 작업을 가져옵니다. 각각의 새로운 연결에 대해 감시 목록은 기본적으로 "default"라는 튜브로 구성됩니다.

소비자는 "사용"을 호출 할 필요가없고 "시계"를 호출 할 필요가 없습니다

관련 문제