wa0x6e / Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
MIT License
159 stars 56 forks source link

Could not open input file: ./bin/resque.php #17

Closed ilevennet closed 11 years ago

ilevennet commented 11 years ago

Hi, i've installed all and queued two jobs.

Starting Worker

./cake CakeResque.CakeResque start
Creating workers
Starting worker ..................... Fail

Reading resque-worker-error.log in cake tmp read:

"bash: php: command not found"

This is stats

[root@server Console]# ./cake CakeResque.CakeResque stats
Resque Statistics
---------------------------------------------------------------
Jobs Stats
   Processed Jobs :            0
   Failed Jobs    :            0
Queues Stats
   Queues count : 2
    - default    :            1 pending job (unmonitored queue)
    - Graph      :            1 pending job (unmonitored queue)
Workers Stats
   Workers count : 0

and this is ShellClass

<?php
/**
 * CakePHP q_GraphShell
 * @author zenomordiante
 */
App::uses('AppShell', 'Console/Command');

class ResqueGraphShell extends AppShell {

    public $uses = array('Members.User', 'Graph');
    public $task = array();

    public function main() {

    }

    //$target_id, $notify_text, $notify_url, $plugin_name
    public function notify(){
        $this->log('ciao!', 'resque');
    }
}

I've also changed some path in CakeResque/Lib/CakeResqueBootstrap.php to reflect my app setting folder What happened?

wa0x6e commented 11 years ago

How do you run PHP script ? Is the PHP executable in your PATH ?

You could use --debug when starting the worker, it'll print the "internal" bash command that CakeResque will run. Copy and run it directly in the shell without the pipe (what's after >>).

ilevennet commented 11 years ago

I have execute it like rot user but...

[root@server Console]# ./cake CakeResque.CakeResque start --debug -u root
Creating workers
[DEBUG] Running command : 
     nohup sudo -u root \
     bash -c "cd '/home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/'; \
       \
     VERBOSE=true \
     QUEUE='default' \
     APP_INCLUDE='/home/voluser/cake/meet/Plugin/CakeResque/Lib/CakeResqueBootstrap.php' \
     INTERVAL=5 \
     REDIS_BACKEND='localhost:6379' \
     REDIS_DATABASE=0 \
     REDIS_NAMESPACE='resque' \
     CAKE='/home/voluser/cake/lib/Cake/' \
     COUNT=1 \
     LOGHANDLER='RotatingFile' \
     LOGHANDLERTARGET='/home/voluser/cake/meet/tmp/logs/resque.log' \
     php './bin/resque.php' \
     >> '/home/voluser/cake/meet/tmp/logs/resque-worker-error.log' \
     2>&1" >/dev/null 2>&1 &
Starting worker ..................... Fail

...the file in /Plugin/CakeResque/vendor/kamisama/php-resque-ex/lib/ is named Resque.php (with capital "R").

php is in the PATH.

is this a problem or it is a label? Running the command without >>...

nohup: ignoring input and appending output to `nohup.out'
Could not open input file: ./bin/resque.php
wa0x6e commented 11 years ago

does /home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/bin/resque exists ?

If not, does it exists with the .php extension ? If not, does /home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/resque.php exists ?

What version of php-resque-ex and CakeResque are you using ?

ilevennet commented 11 years ago

The file Exist. File/Folder Permissions are ok (All to www-user). Initially was root because using composer that download and create the files/folder.

I'm using Cake PHP 2.3.2 (last stable). CakeResque is actual master (I've reinstalled all this morning doing tests

Thanx!

wa0x6e commented 11 years ago

What does it say when you do

cd '/home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/

then

php './bin/resque.php'

ilevennet commented 11 years ago

the results.

[root@server php-resque-ex]# php './bin/resque.php'
Set QUEUE env var containing the list of queues to work.
wa0x6e commented 11 years ago

And this one ?

cd '/home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/'; \
   \
 VERBOSE=true \
 QUEUE='default' \
 APP_INCLUDE='/home/voluser/cake/meet/Plugin/CakeResque/Lib/CakeResqueBootstrap.php' \
 INTERVAL=5 \
 REDIS_BACKEND='localhost:6379' \
 REDIS_DATABASE=0 \
 REDIS_NAMESPACE='resque' \
 CAKE='/home/voluser/cake/lib/Cake/' \
 COUNT=1 \
 LOGHANDLER='RotatingFile' \
 LOGHANDLERTARGET='/home/voluser/cake/meet/tmp/logs/resque.log' \
 php './bin/resque.php'
ilevennet commented 11 years ago

I have modify cause error in: cd /home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/; QUEUE='default' APP_INCLUDE='/home/voluser/cake/meet/Plugin/CakeResque/Lib/CakeResqueBootstrap.php' INTERVAL=5 REDIS_BACKEND='localhost:6379' REDIS_DATABASE=0 REDIS_NAMESPACE='resque' CAKE='/home/voluser/cake/lib/Cake/' COUNT=1 LOGHANDLER='RotatingFile' LOGHANDLERTARGET='/home/voluser/cake/meet/tmp/logs/resque.log' php './bin/resque.php' without "\" but no result have. Seems started. No message on screen

I have opened another window terminal and digits "stats"

Jobs Stats
   Processed Jobs :            1
   Failed Jobs    :            1

Queues Stats
   Queues count : 2
    - default    :            0 pending jobs
    - Graph      :            1 pending job (unmonitored queue)

Workers Stats
   Workers count : 1
    REGULAR WORKERS
    * server.volumeet.com:10990:default
       - Started on     : Tue Apr 23 17:38:59 CEST 2013
       - Processed Jobs : 0
       - Failed Jobs    : 0

"default" queue now is empty!

wa0x6e commented 11 years ago

So the problem is not coming from inside CakeResque, but from the call to the php executable.

cd to the folder cd /home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/;

if php './bin/resque.php' works, the problem is coming from the start of the command, try these command

1 : sudo -u root bash -c "'php ./bin/resque.php'" 2 : sudo -u root php './bin/resque.php' 3 : php './bin/resque.php'

ilevennet commented 11 years ago

This is the results.


[root@server ~]# cd /home/voluser/cake/meet/Plugin/CakeResque/vendor/kamisama/php-resque-ex/
[root@server php-resque-ex]# php './bin/resque.php'
Set QUEUE env var containing the list of queues to work.
[root@server php-resque-ex]# sudo -u root php './bin/resque.php'
sudo: php: command not found
[root@server php-resque-ex]# sudo -u root bash -c "'php ./bin/resque.php'"
bash: php ./bin/resque.php: No such file or directory
[root@server php-resque-ex]# 

Now i try to change some permissions and check php executable for www-user

UPDATE: Reading http://kamisama.me/2012/10/12/background-jobs-with-php-and-resque-part-4-managing-worker/#starting-worker

and launching:

[# QUEUE='default' VVERBOSE=1 php './bin/resque.php'
[14:27:58 2013-04-24] *** Starting worker server.meet.com:27839:default** 
[14:27:58 2013-04-24] Registered signals** 
[14:27:58 2013-04-24] Checking default
** [14:27:58 2013-04-24] Sleeping for 5
** [14:28:03 2013-04-24] Checking default
** [14:28:03 2013-04-24] Sleeping for 5
^C*** Exiting...
** [14:28:05 2013-04-24] No child to kill.
** [14:28:05 2013-04-24] Checking default
** [14:28:05 2013-04-24] Sleeping for 5
[root@server php-resque-ex]# 

There is problem with parameters? with bash syntax?

Launching php './bin/resque.php' get this error (problem reading CakePhp console cass...)

** [14:44:39 2013-04-24] Sleeping for 5
** [14:44:44 2013-04-24] Checking default
** [14:44:44 2013-04-24] Found job on default
*** got {"queue":"default","id":"98772755b91c76981c05b1feb1feeca2","class":"ResqueGraphShell","args":[["notify"]]}
** [14:44:44 2013-04-24] Forked 28333 for ID:98772755b91c76981c05b1feb1feeca2
*** Processing ID:98772755b91c76981c05b1feb1feeca2 in default
*** {"queue":"default","id":"98772755b91c76981c05b1feb1feeca2","class":"ResqueGraphShell","args":[["notify"]]} failed: Could not find job class ResqueGraphShell.
** [14:44:44 2013-04-24] Checking default
** [14:44:44 2013-04-24] Sleeping for 5
wa0x6e commented 11 years ago

Server $PATH issue when using root, not related to plugin itself. Fixed offline.

NaimishS commented 10 years ago

i am having similar problem. Can i know what was the exact solution here.... i am not a so good with debugging....

wa0x6e commented 10 years ago

Check that you are starting your workers with the right user, and that user have access to the php script

NaimishS commented 10 years ago

yes i have the right user and has permission. My PHP version is 5.5.10 could that be an issue in some way? I am able to create worker with 'QUEUE=notification VVERBOSE=1 php resque.php' but not with './cake CakeResque.CakeResque start'

rogerwu99 commented 9 years ago

Hi - I was wondering if you ever figured this out? I have the same issue and on top of that the workers created from resque.php are polling but never finding the jobs in the queue.... Running Stats shows 0 Workers, 0 Failed Jobs, 0 Processed Jobs, 1 Queue, 8 Pending Jobs...