GithubHelp home page GithubHelp logo

fresque's Introduction

#Fresque Build Status Coverage Status Dependency Status Latest Stable Version

Fresque is a command line tool to manage your php-resque workers.

##Prerequisites

If you don't know what is resque or redis, take a look at their official website :

This tool is intended to facilitate your life by making interfacing with php-resque more easier and more friendly. You should already have some knowledge about php-resque, and have php-resque installed and running. I'll assume in this tutorial that you have sufficient knowledge to start a worker normally with php-resque.

##Requirements

  • Redis
  • sudo package installed on your system

php-resque will be installed automatically as a composer dependency.

##What is Fresque

Fresque is a command line tool to manage your php-resque workers

# Start a worker without fresque
$ QUEUE=file_serve php resque.php

# Starting a worker with fresque
$ fresque start -q file_serve

It's more friendly, and provides more options, like restart, stop, etc … Php-resque, and resque, by default doesn't provide an out-of-the-box way to stop your workers. You have to directly kill the worker process. With Fresque, you'll enjoy stopping and restarting your workers at gogo. No more system process handling!

##Installation

By cloning the git repo

$ git clone git://github.com/kamisama/Fresque.git

cd to the Fresque folder you just cloned

$ cd Fresque

Then download Composer

$ curl -s https://getcomposer.org/installer | php

Finally, install dependencies

$ php composer.phar install

Using Composer

If your application is already using Composer, just add Fresque in your composer dependencies

"require": {
    "fresque/fresque": "~1.2.0"
}

and update the dependencies with composer update

##Configuration

A fresque.ini file is provided to set the workers default parameters, and other options used by fresque, such as redis connection options. It's well documented, and you shouldn't have difficulties editing it.

##Usage

For convenience, you should add the fresque executable to your system path. You can just then call fresque with

$ fresque <command>

Or if you didn't add it,

$ cd /path/to/fresque
$ ./fresque <command>

If installed as a composer dependency, it's also available in composer bin folder

$ vendor/bin/fresque <command>

There's a bunch of interesting commands available :

Examples are available at the end of this section.

  • start

To start a new resque worker. By default, it will use the default configuration defined in you fresque.ini for the queue name, the pooling frequency, and other options. You can override all of them with an option flag. Available options :

-u or --user : User running the php process. Should be the user running your php application, usually www-data for apache. Using a different user could lead to permissions problems.

-q or --queue : A list of queues name polled by the worker, separated with a comma.

-i or --interval : Polling frequency. Number of seconds between each polling.

-n or --workers : Number of workers working on the same queues.

-l or --log : Absolute or relative path to the log file. You can set a different log for each worker. The --user must have permission to read and write to that file (and the parent folder, since the file will be created if non-existent). Relative path is relative to the fresque folder.

  • startScheduler

To start the scheduler worker.

-i or --interval : Polling frequency. Number of seconds between each polling.

Scheduler worker is disabled by default, enable it in the configuration file, in the [Scheduler] section. When enabled, it'll be automatically started when using load().

Only one scheduler worker can run at the same time

  • stop

To stop workers. Will wait for all jobs to finish, then stop the worker. If more than one worker is running, a list of workers will be displayed, to choose the worker to stop.

-f or --force : Stop worker immediately, without waiting for the current job to finish processing. This will fail the current job. -w or --all : Stop all workers at once, skipping the worker menu.

  • pause

To pause workers. Similary to stop, you'll be prompted with a worker list if more than one worker is available.

-w or --all : Stop all workers, skipping the worker menu.

  • resume

To resume paused workers. Again, you'll be prompted with a worker list if there is more than one paused worker.

-w or --all : Stop all workers, skipping the worker menu.

  • restart

To restart all the workers, keeping their settings.

  • load

To start a batch of pre-defined workers (set in your configuration file). See fresque.ini for more informations.

  • stats

Display total number of failed/processed jobs, as well as various stats for each workers and queues.

  • tail

Tail a worker's log. If you have more than one log file, you'll be prompted with list of log.

  • enqueue

Add a job to a queue. Takes 3 arguments :

queuename : Name of the queue you will enqueue this job to jobclass : Name of the class that will perform the job, and that your application autoloader will have to load. arguments : comma separated list of arguments, passed to the job.

Will print the Job ID if the job is successfully enqueued.

Successfully enqueuing a job does not mean it will perform it successfully

  • test

Test your configuration. If no options are provided, it will test your fresque.ini. It accepts all type of options.

Finally, there's some global options, that can be used for all commands. Default value in your config file will be used unless you use these.

-s or --host : Redis hostname

-p or --port : Redis port

-b or --lib : Absolute path to the php-resque library. Used when you already have your own, and don't want to use the one shipped with fresque.

-c or --config : Absolute path to your config file. You can use different config for different workers. Default one is fresque.ini, in the same directory as the executable.

-a or --autoloader : Absolute path to your application entry point. Usually, it should be the file that will autoload all your job classes.

##Examples

Let's start a worker with the default settings defined in the config file (fresque.ini):

$ fresque start

Let's start another worker, polling the activity queue, with a polling frequency of 1 second. Also, we'll want to have two workers working on this queue:

$ fresque start -q activity -i 1 -n 2

If we want another worker, working on the queues default and activity at the same time:

$ fresque start -q default,activity

Oh wait, we have another resque on another redis server. we'll want to log its activities in another log file: remote.log

$ fresque start -s 192.168.1.26 -p 6390 -q myspecialqueue -l /path/to/remote.log
  • -s 192.168.1.26 is the address of the redis server
  • -p 6390 is the redis server port
  • -q is the queuename
  • -l is the path to the log file

If you have your config file elsewhere, and your php-resque lib elsewhere also

$ fresque start -c /path/to/my-config.ini -b /path/to/my/custom/php-resque

To view stats of your workers (to know how many you have, processed/failed jobs count, uptime, etc ...)

$ fresque stats

It should output something like that

-----------------
Resque statistics
-----------------

Jobs Stats
   Processed Jobs : 18,617
   Failed Jobs    :    319

Queues Stats
   Queues count : 3
        - default           : 0 pending jobs
        - myspecialqueue    : 0 pending jobs
        - activity          : 0 pending jobs

Workers Stats
   Active Workers : 6
	Worker : KAMISAMA-MAC.local:33197:default
	 - Started on     : Wed May 16 00:33:04 EDT 2012
	 - Uptime         : less than a minute
	 - Processed Jobs : 0
	 - Failed Jobs    : 0
	Worker : KAMISAMA-MAC.local:33207:default
	 - Started on     : Wed May 16 00:33:08 EDT 2012
	 - Uptime         : less than a minute
	 - Processed Jobs : 0
	 - Failed Jobs    : 0
	Worker : KAMISAMA-MAC.local:33215:myspecialqueue
	 - Started on     : Wed May 16 00:33:10 EDT 2012
	 - Uptime         : less than a minute
	 - Processed Jobs : 0
	 - Failed Jobs    : 0
	Worker : KAMISAMA-MAC.local:33232:activity
	 - Started on     : Wed May 16 00:33:16 EDT 2012
	 - Uptime         : less than a minute
	 - Processed Jobs : 0
	 - Failed Jobs    : 0
	Worker : KAMISAMA-MAC.local:33233:activity
	 - Started on     : Wed May 16 00:33:16 EDT 2012
	 - Uptime         : less than a minute
	 - Processed Jobs : 0
	 - Failed Jobs    : 0
	Worker : KAMISAMA-MAC.local:33223:default,activity
	 - Started on     : Wed May 16 00:33:13 EDT 2012
	 - Uptime         : less than a minute
	 - Processed Jobs : 0
	 - Failed Jobs    : 0

Remember that you can use the global options (-s, -p etc …) with any command

$ fresque stop -c /path/to/my-config.ini -s 192.168.1.26

Let's enqueue a job to the activity queue

$ fresque enqueue activity PageVisit "5,/index.php,158745693"

php-resque will then run this job, by instantiating the class PageVisit, then calling the perform() method with the arguments 5, /index.php and 158745693.

In order to instantiate the PageVisit class, php-resque should know where to find it. That should be done inside your application autoloader (either by using an autoloader, of an include/require).

Oh, and if you want to restart all your workers for whatever reasons

$ fresque restart

If you're finished, and want to stop all workers, just

$ fresque stop --all

It'll spout something like that

----------------
Stopping workers
----------------
Killing 6 workers ...
Killing 33197 … Done
Killing 33207 … Done
Killing 33215 … Done
Killing 33232 … Done
Killing 33233 … Done
Killing 33223 … Done

###Starting all your favorites workers at once

We've just created 6 workers, calling start 5 times (remember, the second start create 2 workers with -n 2). But there's a way to start all of them with only one command, useful when you have a lot of workers that you have to start each time.

Just set all your workers settings in the config file in the [Queues] section (walkthrough available in the config file), then start all of them with

$ fresque load

##Notes

###You can test your config with test

A testing tool for testing your configuration file is provided, by calling test. It will test the minimum requirements to run fresque :

  • Your redis hostname and port are not null
  • You can connect to the redis server with the specified hostname:port
  • The log file exist and is writeable, or if it doesn't exists, the parent directory is writeable
  • The path to the php-resque libraries is valid
  • The path to your application autoloader is valid

You can test more than the settings inside your config file, by passing options. An option will override the setting defined in the config

$ fresque test -s 195.168.1.26 -p 6890

This will test your config file, but with the specified redis hostname and port.

You can also test another config file

$ fresque test -c /my/other/config/file.ini

A test result will looks like

---------------------
Testing configuration
---------------------
Testing configuration
Redis configuration .....OK
Redis server ............OK
Log File ................OK
PHPResque library .......OK
Application autoloader ..OK

Your settings seems ok

##Known issues

###stop command doesn't behave as expected

Case 1: it says 'no such process' when stopping a worker

This happens when the saved list of workers is not synchronized with the real state of the workers on the system. A worker was stopped, and fresque wasn't notified.

The main and usual cause is that you didn't stop the workers with the stop command, like when you reboot the machine, without stopping the workers beforehand.

Solution: Stop all your workers using stop --all, then use reset to clear fresque cache, and start your workers again.

Case 2: it says 'no permission'

You don't have permission to manipulate the worker process.

Solution: You have to start and stop the worker with the same user. If you used start --user=www-data to start your worker, use stop --user=www-data to stop it. To avoid that type of problem, always use the same user for all your workers (usually the apache user), and set it by default in the fresque.ini.

Case 3: the stopped worker sometime still appear in the worker list for a few seconds

You just used stop, and it stopped a worker. You immediately use stop again, and the worker is still here.

Solution: Do nothing. It's perfectly normal, stopping a worker can take some time (it'll wait for the job to finish, or wait for the next polling to stop).

##Notes

###Consult your logs

Logs tell you all you need to know about the issue of a job, and the current status of your php-resque workers. It tells you when a job is enqueued, when a job is about to being performed, and its final state (success/fail). It also display all php related errors that may occurs. Check them frequently, as fresque doesn't capture those errors.

##Sudo

sudo is a program for Unix-like computer operating systems that allows users to run programs with the security privileges of another user

Since you're usually not logged in on the shell under the same user as the one your webserver us running under, sudo is required to start and manipulate the workers on behalf of the php user.

Starting your workers under another user could lead to permission problems.

##Background

Fresque is a derivated works from my other plugin, cake-resque, a command line tool to manage php-resque, but inside cakephp console. Very convenient, but limited to only cakephp framework. I wanted to release a tool that can work anywhere, as long as you have a terminal.

##Credits

  • PHP-Resque is written by Chris Boulton
  • Based on Resque by defunkt
  • Fresque by Wan Qi Chen (kamisama)

fresque's People

Contributors

apankov avatar bar avatar cyrilmazur avatar jnmik avatar joeholdcroft avatar mglinski avatar pwhelan avatar ruudk avatar wa0x6e avatar wildsurfer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fresque's Issues

Fresque and Monit

I am using Fresque for my PHP project background jobs. I am monitoring Apache, Mysql and other important processes using Monit . I also want to add Fresque processes in Monit but I am unable to find PID files for worker processes. I have reviewed PHP-Resque library code and it seems that it does support and generate PID files for worker processes in /var/run/resque/ directory. Please guide me how I can achieve it using Fresque.

resume command doesn't work

Hi,
after starting some workers with "fresque -start" the system correctly handles "fresque - pause". Within the log file I can read
[notice] [15:51:55 2014-10-22] USR2 received; pausing job processing

but trying "fresque -resume" nothing happens. Workers are not working and within the log file the only new lines are

[info] [15:53:15 2014-10-22] Sleeping for 5

and the workers don't consume jobs.
Trying also the stop command, it doesn't work.

Here you can find some details about my environment

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"

PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep 4 2014 06:56:34)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

Regards,

Workers disappearing

Probably not the best place to ask this but is there any way to get more debugging information my workers seem to stop every couple of days with nothing in the logs? Can't find much on the php-resque github either about this?

Restart is not working properly

Hi,

When I start 5 workers 2 times it has 10 workers started.

$ ./fresque start -n 5
Forking 5 new PHP Resque worker services (queue:default user:Ruud)

$ ./fresque start -n 5
Forking 5 new PHP Resque worker services (queue:default user:Ruud)

$ ./fresque stats
PHPResque Statistics

Jobs Stats
   Processed Jobs : 0
   Failed Jobs    : 0

Workers Stats
   Active Workers : 10

This is correct. But when I now hit the restart button and look at the stats it shows me unexpected behavior:

$ ./fresque restart
Shutting down Resque Worker complete
Killing 10 workers ...
Killing 21057
Killing 21067
Killing 21085
Killing 21078
Killing 21079
Killing 21061
Killing 21053
Killing 21054
Killing 21090
Killing 21082
Forking 5 new PHP Resque worker services (queue:default user:Ruud)
Forking 1 new PHP Resque worker service (queue:default user:Ruud)

$ ./fresque stats
PHPResque Statistics

Jobs Stats
   Processed Jobs : 0
   Failed Jobs    : 0

Workers Stats
   Active Workers : 4
    Worker : iMacRuud.local:21130:default
     - Started on     : Fri Aug 03 08:06:15 UTC 2012
     - Uptime         : less than a minute
     - Processed Jobs : 0
     - Failed Jobs    : 0
    Worker : iMacRuud.local:21134:default
     - Started on     : Fri Aug 03 08:06:15 UTC 2012
     - Uptime         : less than a minute
     - Processed Jobs : 0
     - Failed Jobs    : 0
    Worker : iMacRuud.local:21138:default
     - Started on     : Fri Aug 03 08:06:15 UTC 2012
     - Uptime         : less than a minute
     - Processed Jobs : 0
     - Failed Jobs    : 0
    Worker : iMacRuud.local:21132:default
     - Started on     : Fri Aug 03 08:06:15 UTC 2012
     - Uptime         : less than a minute
     - Processed Jobs : 0
     - Failed Jobs    : 0

Why does it now has 4 workers instead of 10? Sometimes its 6 workers. I don't get it.

Composer Requirements

Are the composer requirements for Fresque up-to-date?

I don't seem to be able to install it via Composer / Packagist - I can't be using chrisboulton/php-resque - only kamisama/php-resque-ex - is this expected? How up-to-date is your fork kept with Chris' version?

Also, if I use the latest version of kamisama/php-resque-ex (1.3.0), I'm unable to install Fresque; I get the following error:

Problem 1
    - Installation request for fresque/fresque 1.3.0 -> satisfiable by fresque/fresque[1.3.0].
    - fresque/fresque 1.3.0 requires kamisama/php-resque-ex ~1.2.5 -> no matching package found.

Any help/ advice is much appreciated!

Failed to start worker when server is booting

Hi,

I'm trying to exec fresque command when sever reboot, to make every server I own will start workers automatically.

I'm using Amazon Linux, and put command "fresque start >> resque.log" to the instance settings "User Data"

The log file show me resque was stated failed, so I tried to change my command in user data to debug, "fresque test >> resque_debug.log" and looks everything fine, redid OK, database OK, etc

Just curious would you give me some advices?

Many thanks
Kai

Worker info not updated

Hi kamisama,

I ran into this scenario >>

  1. From the fresque logs, I see these entries :
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
    [2013-10-05T16:27:31+00:00] Exiting...
    [2013-10-05T16:27:31+00:00] CONT received; resuming job processing
  2. When I run "ps -ef", I don't use any worker process running.
  3. When I run "fresque stats", it lists down the previously listed workers.
  4. I tried to run "fresque stop", yet the worker info is still registered there.

Any idea how to solve this?

Scalability: Scaling fresque

Hello,
How to scale the Fresque implementation? I am scaling my application and have 4 servers behind load balancer. Currently I am running fresque in all 4 servers. Is there any other method?

Thanks,
Girish

Timezone

When I set the date.timezone to 'PRC' , the worker's Uptime seems not correct.
image

How to Fix it ?

Unable to create more than one worker

Hi,
I have been using Fresque in production for about 1 year now, and haven't had any problems, but recently I deployed fresque on new servers and for some reason only one worker is being created. Also the stats for the worker aren't visible when i check them.

How can i resolve this?
Thanks

Version bump? 1.3.2 or 1.4.0?

@CyrilMazur introduced a rad new feature to include environment variables in each worker, but the 1.3.1 release was set in May 2015, and your pull in June never bumped the version number.

I'd include dev-master, but am wary of any other future merges that may break things or new features that you include in a v2 version that breaks dependencies. Just a thought. Will probably fork and include a cloned version until I hear back. Hope you consider it!

Workers not starting

I have installed Fresque using composer. I run the test with command
fresque test
and it showed the output that setup is ready. But when I try to start workers using
fresque -n 5
it shows Done message. But when i see stats, it tells that there is no active worker. When I try to stop workers, it tells that there is no active workers. Can you please tell me what can be the issue?

need for authentication support

Beacuse the origin php-resque don't support redis authentication, so I chose your php-resque-ex. Then I found out this awsome command line tool, but without redis authentication, >_<
In production environment, redis authentication is almost mandatory.

Broken bin when install from Composer on Debian

When i install Fresque from composer on Debian, i can't start it from vendor/bin/fresque because of error:

root@debian:/tmp/cg2# ./vendor/bin/fresque
./vendor/bin/
Could not open input file: ./vendor/bin//lib/init.php

vendor/bin/fresque is just a symlink to vendor/fresque/fresque/fresque

fresque -> ../fresque/fresque/fresque

So, when it try to do this

LIB=${0/%fresque/}
exec php -q ${LIB}/lib/init.php "$@"

${LIB) is vendor/bin/ and, of course, vendor/bin//lib/init.php doesn't exist.

If i install on windows or windows shared folder in linux system (without symlinks), Composer create binary file like this:

#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd '../fresque/fresque'
BIN_TARGET="`pwd`/fresque"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"

and it works like it should.

Fresque has stopped processing jobs once a month

I can't really figure out why and it's hard to for me to debug but last month (March 1st) and this month (April 5th) fresque stopped polling for jobs. It was still searching for new jobs, but it just wouldn't see that they were there and grab them. resque-web showed 900+ on the queue, but none would be processing. Restarting the workers works.

I'm using php-resque-ex as the library. Everything else is pretty much default.

Not sure if this is something you've seen?

Question : Multiple Workers

Hi kamisama,

Greetings.
Have you come across any scenario or conflict that a multi-worker queue might access the same data at the same time? Meaning at a point of time, worker A and worker B both pulling a job ID from a queue at the same time.... Or to rephrase it ..... "multiple workers running the same job"..

can pass -c to enquue command

Hi,

when i try to launch this command:
./fresque enqueue queuename classjob "params" -c another-config.ini
the options to load different config doesn't work

every works fine when launching
./fresque (start|load|stop) -c another-config.ini

A Sample of fresque.ini

Hi kamisama,

Would you mine share the fresque.ini that will yield that results in your readme example?

I'm trying to configure the file with something like this :

[Queues]
high[interval] = 5
high[workers] = 4
medium[interval] = 60
medium[workers] = 2
low[interval] = 300
low[workers] = 1

But this is the result when I do a stats :


Resque statistics

Jobs Stats
Processed Jobs : 0
Failed Jobs : 0

Queues Stats
Queues count : 0

Workers Stats
Active Workers : 3
Worker : ip-66-0-0-101:6953:default
- Started on : Wed Oct 02 08:05:05 UTC 2013
- Uptime : 8 minutes and 39 seconds
- Processed Jobs : 0
- Failed Jobs : 0
Worker : ip-66-0-0-101:6937:default
- Started on : Wed Oct 02 08:05:04 UTC 2013
- Uptime : 8 minutes and 40 seconds
- Processed Jobs : 0
- Failed Jobs : 0
Worker : ip-66-0-0-101:6920:default
- Started on : Wed Oct 02 08:05:04 UTC 2013
- Uptime : 8 minutes and 40 seconds
- Processed Jobs : 0
- Failed Jobs : 0

Any idea where could have gone wrong? I started fresque with "fresque load" command.

Worker starter bash script

Hi,

The way the worker starter bash script is generated is not platform independent.

I'm running Debian 6 in my production server, and the following changes were needed to make it working.

  1. my nohup doesn't accept -u switch (you might want to apply the switch after checking if it accepts the switch or no)
  2. there is no sudo installed in my OS (same as many production environment)
  3. there is an extra double quote after 2>&1 in Fresque.php line 444

I downloaded the latest version from Composer. Please let me know if you need me to create a pull request or patch.

Beside the above, it's a great software and thank you.

Regards.

Specifying worker names with stop command

I am going to implement a feature that allows users to specify the worker to kill in command line. This is useful if you are using some automation/CI tools (jenkins, ansible, puppet etc). There are going to be two additional options to the stop command: --worker and --count.

The --worker option allows you to specify a queue name to kill. By default it will kill all workers with that name.

The --count option works in tandem with the --worker option and allows you to specify how many to kill.

I'm not sure if you accept feature additions to your codebase, but if you want, I can make a pull request, implement it and then merge back into your repo. That way others can benefit.

Let me know what you think

PHP Warning at the end of 'fresque test'

In Fresque.php:1136

$this->runtime['type'] = 'regular';

adds a string to the config, but the test function in Fresque.php:1038 is expecting an array. String values should there be handled differently or excluded.

Test it with:
fresque -c my_config.ini

Cannot specify include file via command line

I am trying to specify an include file via command line. Unfortunately, both APP_INCLUDE and -a are ignored. I have tried

sudo ./fresque start -a /opt/fresque/autoloader2.php

and

sudo APP_INCLUDE=/opt/fresque/autoloader2.php ./fresque start

with the same result. But if I specify it within the ini file, it is correctly loaded.

Also, is it possible to load a queue specific include file? I tried setting the following in the ini file

[Queues]
VideoConvertor[include] = /opt/fresque/autoloader2.php
; VideoConvertor is my queue name

But that too did not work.

ResqueScheduler into Fresque

Hi, just a quick question - I hope you can point me in the right direction :)

What is the best way to integrate the ResqueScheduler into Fresque

I can see that there are registerSchedulerWorker and other related methods in the fresque controls. Should I start a worker separately? If so how do I tell fresque the worker is running?

question re fresque.ini

Below is an extract from my fresque.ini file. Based on that I believe that adding a job to the queue job-onboard-mailer will cause it to be done at a 360 second interval, the next time that queue is polled. But that doesn't seem to be the case according to my log file, an extract of which is pasted below. It seems to be doing the job instantly. Could you please advise if my settings are wrong or if I have misunderstood something?

Also, is there any documentation for the scheduler feature?

Thanks.

[Default]
; Default name of the queue the worker will be working one
; A worker can work on more than one queue, just separate
; the name with a commas, e.g "defaultone,defaultwo"
queue = job-worker

; Polling frequency
; Number of seconds to sleep between each polling
interval = 5

; Number of workers to fork
; e.g putting 2 will start to workers with exactly
; the same settings
workers = 1

[Queues]

job-dispatcher[workers] = 1
job-mailer[workers] = 1
job-worker[workers] = 6
job-deleter[workers] = 1
job-welcome-mailer[workers] = 1
job-onboard-mailer[workers] = 1
job-create-mp3[workers] = 1
job-onboard-mailer[interval] = 360
job-welcome-mailer[interval] = 180

[2015-08-11T11:56:30+01:00] Processing ID:bc7285fbe7053d1048f94dd5018584a9 in job-onboard-mailer
[2015-08-11T11:56:30+01:00] done ID:bc7285fbe7053d1048f94dd5018584a9
[2015-08-11T11:56:30+01:00] got {"queue":"job-onboard-mailer","id":"ddbefb12b4bfa17acc505e4a64abb42d","class":"Byta\JobBundle\Job\JobSendOnboardEmail","args":[{"messageID":33,"created":"2015-08-11 11:53:45","type":"meta"}]}
[2015-08-11T11:56:30+01:00] Processing ID:ddbefb12b4bfa17acc505e4a64abb42d in job-onboard-mailer
[2015-08-11T11:56:30+01:00] done ID:ddbefb12b4bfa17acc505e4a64abb42d
[2015-08-11T11:56:30+01:00] got {"queue":"job-onboard-mailer","id":"c87943072007a0bf3d9a925cc225b1f1","class":"Byta\JobBundle\Job\JobSendOnboardEmail","args":[{"messageID":33,"created":"2015-08-11 11:53:45","type":"meta"}]}
[2015-08-11T11:56:30+01:00] Processing ID:c87943072007a0bf3d9a925cc225b1f1 in job-onboard-mailer
[2015-08-11T11:56:30+01:00] done ID:c87943072007a0bf3d9a925cc225b1f1
[2015-08-11T11:56:30+01:00] got {"queue":"job-onboard-mailer","id":"e265c5ee44fa385fe945f4276cce2c15","class":"Byta\JobBundle\Job\JobSendOnboardEmail","args":[{"messageID":33,"created":"2015-08-11 11:53:45","type":"meta"}]}

Starting worker ..................... Fail

When attempting to start a worker using a normal user account, I get the following:

[rstanchak@myhost ] ./fresque start
----------------
Creating workers
----------------
Starting worker ..................... Fail

Running with --debug

[rstanchak@myhost ] ./fresque start --debug
----------------
Creating workers
----------------
[DEBUG] Will start 1 workers
[DEBUG] Starting worker (1)
[DEBUG] Running command :
        nohup sudo -u 'rstanchak' \
        bash -c "cd '/var/www/html/resque-test/vendor/fresque/fresque/../../../vendor/kamisama/php-resque-ex';  \
        VERBOSE=true  \
        QUEUE='StationProxyJobs' \
        PIDFILE='/var/www/html/resque-test/vendor/fresque/fresque/tmp/13809048873761' \
        APP_INCLUDE='/var/www/html/resque-test/vendor/fresque/fresque/../../../vendor/autoload.php' \
        INTERVAL='5' \
        REDIS_BACKEND='localhost:6379' \
        REDIS_DATABASE='0' \
        REDIS_NAMESPACE='resque' \
        COUNT=1 \
        LOGHANDLER='' \
        LOGHANDLERTARGET='' \
        php ./bin/resque \
         >> '/var/www/html/resque-test/vendor/fresque/fresque/../../../fresque.log' 2>&1" >/dev/null 2>&1 &
Starting worker ..................... Fail

just the shell command...

[rstanchak@myhost ] sudo -u 'rstanchak' \
>         bash -c "cd '/var/www/html/resque-test/vendor/fresque/fresque/../../../vendor/kamisama/php-resque-ex';  \
>         VERBOSE=true  \
>         QUEUE='MyJobs' \
>         PIDFILE='/var/www/html/resque-test/vendor/fresque/fresque/tmp/13809048873761' \
>         APP_INCLUDE='/var/www/html/resque-test/vendor/fresque/fresque/../../../vendor/autoload.php' \
>         INTERVAL='5' \
>         REDIS_BACKEND='localhost:6379' \
>         REDIS_DATABASE='0' \
>         REDIS_NAMESPACE='resque' \
>         COUNT=1 \
>         LOGHANDLER='' \
>         LOGHANDLERTARGET='' \
>         php ./bin/resque"
Sorry, user rstanchak is not allowed to execute '/bin/bash -c cd '/var/www/html/resque-test/vendor/fresque/fresque/../../../vendor/kamisama/php-resque-ex';          VERBOSE=true          QUEUE='MyJobs'         PIDFILE='/var/www/html/resque-test/vendor/fresque/fresque/tmp/13809048873761'         APP_INCLUDE='/var/www/html/resque-test/vendor/fresque/fresque/../../../vendor/autoload.php'         INTERVAL='5'         REDIS_BACKEND='localhost:6379'         REDIS_DATABASE='0'         REDIS_NAMESPACE='resque'         COUNT=1         LOGHANDLER=''         LOGHANDLERTARGET=''         php ./bin/resque' as rstanchak on myhost.

Based on this, it is clear that the user starting the job must be in the sudoers file.

Future users may find the following changes helpful:
(1) document the 'sudo' requirement in README
(2) be able to run fresque without requiring sudo
(3) capture the shell error and provide this detail if the worker fails to start

Other than this minor hang-up, I really like fresque - very convenient!

Rescheduler Failing (Not Found)

Hi,

I'm trying to use rescheduler inside Fresque in one of my loaded classes and i get:

PHP Fatal error: Class 'ResqueScheduler' not found

I have already started it using fresque startScheduler.

How do I load the ResqueScheduler class?

Thanks.

Regards,
Mike.

Failed Jobs

Firstly thanks for this Nice tool.

The logs file gets bigger and bigger on the server after time. So Is there a quick way to check why our jobs failed or can we get any notification (email etc) when a job fails. Thanks.

Memory Problem free();

I have problem while using this library ? why this is happening

var/www/html/social-project/vendor/fresque/fresque# *** Error in `php': free(): invalid next size (fast): 0x0000564fe3ad5be0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f882c55e7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f882c56737a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f882c56b53c]
php(cleanup_ps_args+0x91)[0x564fe36d5971]
php(main+0x3c4)[0x564fe34b8704]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f882c507830]
php(_start+0x29)[0x564fe34b88f9]
======= Memory map: ========
564fe33d4000-564fe3784000 r-xp 00000000 fd:01 59250                      /usr/bin/php7.0
564fe3984000-564fe39fd000 r--p 003b0000 fd:01 59250                      /usr/bin/php7.0
564fe39fd000-564fe3a0d000 rw-p 00429000 fd:01 59250                      /usr/bin/php7.0
564fe3a0d000-564fe3a29000 rw-p 00000000 00:00 0
564fe3ac3000-564fe3c90000 rw-p 00000000 00:00 0                          [heap]
7f8824000000-7f8824021000 rw-p 00000000 00:00 0
7f8824021000-7f8828000000 ---p 00000000 00:00 0
7f8829cc5000-7f8829cdb000 r-xp 00000000 fd:01 1964                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8829cdb000-7f8829eda000 ---p 00016000 fd:01 1964                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8829eda000-7f8829edb000 rw-p 00015000 fd:01 1964                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7f8829edb000-7f882a04d000 r-xp 00000000 fd:01 25730                      /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f882a04d000-7f882a24d000 ---p 00172000 fd:01 25730                      /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f882a24d000-7f882a257000 r--p 00172000 fd:01 25730                      /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f882a257000-7f882a259000 rw-p 0017c000 fd:01 25730                      /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f882a259000-7f882a25d000 rw-p 00000000 00:00 0
7f882a25d000-7f882bb13000 r-xp 00000000 fd:01 25930                      /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7f882bb13000-7f882bd12000 ---p 018b6000 fd:01 25930                      /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7f882bd12000-7f882bd13000 r--p 018b5000 fd:01 25930                      /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7f882bd13000-7f882bd14000 rw-p 018b6000 fd:01 25930                      /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7f882bd14000-7f882bd35000 r-xp 00000000 fd:01 2003                       /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f882bd35000-7f882bf34000 ---p 00021000 fd:01 2003                       /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f882bf34000-7f882bf35000 r--p 00020000 fd:01 2003                       /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f882bf35000-7f882bf36000 rw-p 00021000 fd:01 2003                       /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f882bf36000-7f882c0b5000 r-xp 00000000 fd:01 25932                      /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7f882c0b5000-7f882c2b5000 ---p 0017f000 fd:01 25932                      /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7f882c2b5000-7f882c2c5000 r--p 0017f000 fd:01 25932                      /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7f882c2c5000-7f882c2c6000 rw-p 0018f000 fd:01 25932                      /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7f882c2c6000-7f882c2ca000 rw-p 00000000 00:00 0
7f882c2ca000-7f882c2e2000 r-xp 00000000 fd:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f882c2e2000-7f882c4e1000 ---p 00018000 fd:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f882c4e1000-7f882c4e2000 r--p 00017000 fd:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f882c4e2000-7f882c4e3000 rw-p 00018000 fd:01 1971                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f882c4e3000-7f882c4e7000 rw-p 00000000 00:00 0
7f882c4e7000-7f882c6a7000 r-xp 00000000 fd:01 1994                       /lib/x86_64-linux-gnu/libc-2.23.so
7f882c6a7000-7f882c8a7000 ---p 001c0000 fd:01 1994                       /lib/x86_64-linux-gnu/libc-2.23.so
7f882c8a7000-7f882c8ab000 r--p 001c0000 fd:01 1994                       /lib/x86_64-linux-gnu/libc-2.23.so
7f882c8ab000-7f882c8ad000 rw-p 001c4000 fd:01 1994                       /lib/x86_64-linux-gnu/libc-2.23.so
7f882c8ad000-7f882c8b1000 rw-p 00000000 00:00 0
7f882c8b1000-7f882cacb000 r-xp 00000000 fd:01 2113                       /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f882cacb000-7f882ccca000 ---p 0021a000 fd:01 2113                       /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f882ccca000-7f882cce6000 r--p 00219000 fd:01 2113                       /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f882cce6000-7f882ccf2000 rw-p 00235000 fd:01 2113                       /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f882ccf2000-7f882ccf5000 rw-p 00000000 00:00 0
7f882ccf5000-7f882cd53000 r-xp 00000000 fd:01 2114                       /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f882cd53000-7f882cf53000 ---p 0005e000 fd:01 2114                       /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f882cf53000-7f882cf57000 r--p 0005e000 fd:01 2114                       /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f882cf57000-7f882cf5e000 rw-p 00062000 fd:01 2114                       /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f882cf5e000-7f882d10f000 r-xp 00000000 fd:01 25943                      /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7f882d10f000-7f882d30e000 ---p 001b1000 fd:01 25943                      /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7f882d30e000-7f882d316000 r--p 001b0000 fd:01 25943                      /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7f882d316000-7f882d318000 rw-p 001b8000 fd:01 25943                      /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7f882d318000-7f882d319000 rw-p 00000000 00:00 0
7f882d319000-7f882d31c000 r-xp 00000000 fd:01 1977                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f882d31c000-7f882d51b000 ---p 00003000 fd:01 1977                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f882d51b000-7f882d51c000 r--p 00002000 fd:01 1977                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f882d51c000-7f882d51d000 rw-p 00003000 fd:01 1977                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f882d51d000-7f882d625000 r-xp 00000000 fd:01 1989                       /lib/x86_64-linux-gnu/libm-2.23.so
7f882d625000-7f882d824000 ---p 00108000 fd:01 1989                       /lib/x86_64-linux-gnu/libm-2.23.so
7f882d824000-7f882d825000 r--p 00107000 fd:01 1989                       /lib/x86_64-linux-gnu/libm-2.23.so
7f882d825000-7f882d826000 rw-p 00108000 fd:01 1989                       /lib/x86_64-linux-gnu/libm-2.23.so
7f882d826000-7f882d894000 r-xp 00000000 fd:01 2062                       /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f882d894000-7f882da94000 ---p 0006e000 fd:01 2062                       /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f882da94000-7f882da95000 r--p 0006e000 fd:01 2062                       /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f882da95000-7f882da96000 rw-p 0006f000 fd:01 2062                       /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f882da96000-7f882daaf000 r-xp 00000000 fd:01 2119                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f882daaf000-7f882dcae000 ---p 00019000 fd:01 2119                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f882dcae000-7f882dcaf000 r--p 00018000 fd:01 2119                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f882dcaf000-7f882dcb0000 rw-p 00019000 fd:01 2119                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f882dcb0000-7f882dcc7000 r-xp 00000000 fd:01 1984                       /lib/x86_64-linux-gnu/libresolv-2.23.so
7f882dcc7000-7f882dec7000 ---p 00017000 fd:01 1984                       /lib/x86_64-linux-gnu/libresolv-2.23.so
7f882dec7000-7f882dec8000 r--p 00017000 fd:01 1984                       /lib/x86_64-linux-gnu/libresolv-2.23.so
7f882dec8000-7f882dec9000 rw-p 00018000 fd:01 1984                       /lib/x86_64-linux-gnu/libresolv-2.23.so
7f882dec9000-7f882decb000 rw-p 00000000 00:00 0
7f882decb000-7f882def1000 r-xp 00000000 fd:01 1966                       /lib/x86_64-linux-gnu/ld-2.23.so
7f882df45000-7f882e0dd000 r--p 00000000 fd:01 28901                      /usr/lib/locale/locale-archive
7f882e0dd000-7f882e0e7000 rw-p 00000000 00:00 0
7f882e0ed000-7f882e0ee000 rw-p 00000000 00:00 0
7f882e0ee000-7f882e0f0000 rw-p 00000000 00:00 0
7f882e0f0000-7f882e0f1000 r--p 00025000 fd:01 1966                       /lib/x86_64-linux-gnu/ld-2.23.so
7f882e0f1000-7f882e0f2000 rw-p 00026000 fd:01 1966                       /lib/x86_64-linux-gnu/ld-2.23.so
7f882e0f2000-7f882e0f3000 rw-p 00000000 00:00 0
7fff9c83b000-7fff9c85c000 rw-p 00000000 00:00 0                          [stack]
7fff9c917000-7fff9c919000 r--p 00000000 00:00 0                          [vvar]
7fff9c919000-7fff9c91b000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Starting worker ..................... Fail

I just had this problem while Fresque worked perfectly.
I stopped jobs, to restart (not through the command restart, but manually).

Then impossible to restart Fresque.

sudo fresque start -q backend --debug output :

[DEBUG] Will start 2 workers
[DEBUG] Starting worker (1)
[DEBUG] Running command :
    nohup sudo -u '_www' \
    bash -c "cd '/workspace/api/lib/Fresque/vendor/kamisama/php-resque-ex';  \
    VERBOSE=true  \
    QUEUE='default' \
    PIDFILE='/workspace/api/lib/Fresque/tmp/14266092016169' \
    APP_INCLUDE='/workspace/api/lib/Fresque/vendor/autoload.php' \
    RESQUE_PHP='/workspace/api/lib/Fresque/vendor/kamisama/php-resque-ex/lib/Resque.php' \
    INTERVAL='2' \
    REDIS_BACKEND='localhost:6379' \
    REDIS_DATABASE='0' \
    REDIS_NAMESPACE='resque' \
    COUNT=1 \
    LOGHANDLER='MongoDB' \
    LOGHANDLERTARGET='' \
    php './bin/resque' \
     >> '/var/log/Fresque/fresque.log' 2>&1" >/dev/null 2>&1 &
Starting worker ..................... Fail

Do you have an idea of the problem?

fresque is stopping everyday

We are using fresque to process jobs in background. But from few days it is stopping almost everyday. what could be the reasons?

php-resque no longer a dependency so test fails

php-resque was removed as a composer dependency in favor of php-resque-ex. However, that was then moved to a suggestion. So now no package of php-resque is included, meaning the Resque class doesn't exist and "fresque test" fails.

Adding back php-resque (dev-master) and updating composer fixed it.

Stop Support for multiple servers

In the stop command add an additional option along with the existing "all workers" option that will only stop workers that have the machines hostname.

Autoloader

I'm trying to figure out what the autoloader.php is supposed look like as there are several different ways to specify autoloaders...

Is there an example available I could crib from?

Thx.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.