Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

FIX: set scheduler type to 'scheduler' upon loading settings, re #23. #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pwhelan
Copy link
Contributor

@pwhelan pwhelan commented Dec 10, 2013

A minor fix for a bunch of undefined index notices.

@pwhelan
Copy link
Contributor Author

pwhelan commented Dec 18, 2013

Adding $this->runtime['Scheduler']['type'] = 'scheduler'; is useless, since it's never used.

There is actually a few conditional checks for it a few lines down.

https://github.com/pwhelan/Fresque/blob/0b01b685ef66c6daefaa5d2f07fe8b30fd101c91/lib/Fresque.php

    if ($this->runtime['Scheduler']['enabled']) {
        if (!empty($this->runtime['Scheduler']['handler']) && $this->runtime['Scheduler']['type'] === 'scheduler') {
            $this->runtime['Log']['handler'] = $this->runtime['Scheduler']['handler'];
        }

        if (!empty($this->runtime['Scheduler']['target']) && $this->runtime['Scheduler']['type'] === 'scheduler') {
            $this->runtime['Log']['target'] = $this->runtime['Scheduler']['target'];
        }

        if (!empty($this->runtime['Scheduler']['interval'])) {
            $this->runtime['Default']['interval'] = $this->runtime['Scheduler']['interval'];
        }
    }

Checking the type there seems unnecessary to me but I kept them in case there is some feature from the CakeResque version you still have not ported across yet.

@ghost ghost assigned wa0x6e Dec 18, 2013
@pwhelan
Copy link
Contributor Author

pwhelan commented Feb 6, 2014

The patch fixed this issue:

[root@localhost click4time.new]# ./vendor/bin/fresque load -c fresque.ini
--------------------------
Loading predefined workers
--------------------------
Loading 6 workers
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
Starting worker ...... Done
PHP Notice:  Undefined index: Scheduler in /vagrant/click4time.new/vendor/fresque/fresque/lib/Fresque.php on line 445

Notice: Undefined index: Scheduler in /vagrant/click4time.new/vendor/fresque/fresque/lib/Fresque.php on line 445
Scheduler Worker is not enabled

Here is my fresque.ini file:

; ::::::::::::::::::::::::::::
; Fresque Configuration File ;
; ::::::::::::::::::::::::::::
;
; This is the default configuration
; file for your fresque application
;
; Most of these settings can be overriden
; through their corresponding option flag
; when running a command

[Redis]

; Hostname of your redis server
; Usually localhost or 127.0.0.1
host    = localhost

; Port number of you redis server
; Default is 6379
port    = 6379

; Redis Database
database = 0

; Redis namespace
; All resque related keys will be prepented with this string
namespace = 'resque'

[Fresque]

tmpdir = /tmp

; Absolute or relative path to php-resque libraries
; A relative path will be relative to the location
; of the fresque cli.
;
; Fresque is shipped with a copy of the php-resque
; library, but it you have already included one in your
; application, and wish to use it, put in its path
lib     = /var/www/html/click4time.new/vendor/kamisama/php-resque-ex

; Absolute path to the entry point of you application
; In order to execute your jobs, php-resque have to know
; about your jobs classes.
; Instead of passing each job classes to php-resque
; one by one, use an autoloader that will autoload
; your jobs classes
include = /var/www/html/click4time.new/httpdocs/cron.php

[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   = *
;
; 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

; User running the fresque process
; It's a system user, who must own the permissions
; to create and edit the log file and run you jobs
; Usually, it's the same user as the one running
; your php process, e.g www-data
user    = apache

; Verbose mode
; Log more debugging informations
; You can also enable verbose mode by using the --verbose
; option when starting a worker
verbose = 0

[Log]

; Path to the log file
; All phpresque activities will be
; recorded into this log
; You can use an absolute or relative path
; Relative path will be relative to the fresque bin file
filename    = /tmp/fresque.log

; Following 2 options are used only if you use
; https://github.com/kamisama/php-resque-ex
; instead of php-resque. It enables more logging
; options, such as logging to a database

; Log Handler used for logging
; Refer to Monolog documentation for a list
; of available handler
; https://github.com/Seldaek/monolog#handlers
; Use the handler name without the "Handler" part
;
; eg : to use MongoDBHandler :
; handler = MongoDB
handler = Cube

; Options used by the handler for initialization
; Options depends on the handler, refer to each
; handler documentation for valid options.
; If handler takes more than one mandatory arguments,
; separate them with a comma
;
; eg : FileRotateHandler takes only one
; mandatory arguments : the filename
; target = path/log.log
;
; eg : CubeHandler takes one url argument
; target : udp://127.0.0.1:1180
target = udp://127.0.0.1:1180


; ---------------------------------------------------------

; Following settings are optionals
; and should be used if you have more than one worker,
; with different settings each.
; It lets you start a bunch of workers at once
;
; Here, you define default settings for your
; different workers.
; Calling `load` in cli will start all of them at once
[Queues]

; Here, we will define two workers : `activity` and `stats`
; Let's start by the `activity` worker
; We set the number of workers to 2, in the following format :
; QUEUENAME[PROPERTY] = VALUE
cron[workers] = 1
cron[interval] = 15

;
; PROPERTY can be any of the key defined in [Default], [Redis],
; [Fresque] or [Log] sections (above)

;
; If you don't set the other properties (interval, user etc ...),
; default value will be used.
; You need to set at least one value, even if it's the
; same as the default one, because fresque will need
; the keyname to capture the queue name

; Here, we set the properties for another worker
; named `stats`

appointments[workers] = 4
appointments[interval] = 15

calendar[workers] = 8
calendar[interval] = 10

;legacy[workers] = 4
;legacy[interval] = 5

payments[workers] = 1
payments[interval] = 60

services[workers] = 2
services[interval] = 30

customers[workers] = 2
customers[interval] = 30

[Scheduler]

; Enable or disable delayed job
enabled = true

; Path to the php-resque-ex-scheduler's library
lib = ./vendor/kamisama/php-resque-ex-scheduler

; Path to the scheduler log file
log = /var/log/resque-scheduler.log

; Optional
; Set the Scheduler worker's polling interval (in seconds)
; Default to interval defined in the [Queue] section above
; interval = 3

; That's all folks !

Use an empty array in array_replace_recursive when there are no arguments.
@pwhelan
Copy link
Contributor Author

pwhelan commented Feb 20, 2014

any chance this will ever get fixed? is there an unknown major change that will fix this implicitly? I know you don't personally use fresque so I am willing to register my fork on packagist.org to move things along.

@wa0x6e
Copy link
Owner

wa0x6e commented Feb 21, 2014

When is that error occuring ? When starting the scheduler worker with fresque startScheduler ? Or only when using fresque load ?

@pwhelan
Copy link
Contributor Author

pwhelan commented Feb 22, 2014

I just tested it and it only seems to happen when the scheduler is enabled and when invoking fresque load but not fresque startScheduler.

@pwhelan
Copy link
Contributor Author

pwhelan commented Mar 25, 2014

Would you like a unit test for this bug?

@pwhelan
Copy link
Contributor Author

pwhelan commented Nov 13, 2014

Any chance of getting this merged? This is quite a show stopper for me.

@pwhelan
Copy link
Contributor Author

pwhelan commented Feb 12, 2015

I got this error running with 1.3.0

PHP Notice:  Undefined index: Scheduler in /var/www/html/dev1/click4time.current/vendor/fresque/fresque/lib/Fresque.php on line 445
Scheduler Worker is not enabled

The last line was in red. Here is my [Scheduler] section in the INI file:

[Scheduler]

; Enable or disable delayed job
enabled = true

; Path to the php-resque-ex-scheduler's library
lib = ./vendor/kamisama/php-resque-ex-scheduler

; Path to the scheduler log file
log = /var/www/html/dev1/click4time.current/log/scheduler.log

; Optional
; Set the Scheduler worker's polling interval (in seconds)
; Default to interval defined in the [Queue] section above
; interval = 3

; That's all folks !

All I ask is for a fix, any fix.

@pwhelan
Copy link
Contributor Author

pwhelan commented Feb 26, 2015

[root@localhost www]# ./vendor/bin/fresque load -c fresque.ini
--------------------------
Loading predefined workers
--------------------------
Loading 8 workers
Starting worker ... Done
Starting worker ... Done
Starting worker ... Done
Starting worker ... Done
Starting worker ... Done
Starting worker ... Done
Starting worker ... Done
Starting worker ... Done
PHP Notice:  Undefined index: Scheduler in ./vendor/fresque/fresque/lib/Fresque.php on line 445
Scheduler Worker is not enabled

Using [08e5d7e].

@pwhelan
Copy link
Contributor Author

pwhelan commented Feb 26, 2015

Adding $this->runtime['Scheduler']['type'] = 'scheduler'; is useless, since it's never used.

The very same member of that array gets used in a conditional not more than 3 lines down.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants