-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
738 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
language: php | ||
|
||
php: | ||
- '7.4' | ||
- '7.3' | ||
- '7.2' | ||
- '7.1' | ||
- '7.0' | ||
- '5.6' | ||
- hhvm | ||
matrix: | ||
exclude: | ||
- php: hhvm | ||
env: ENABLE_REDIS_EXT=1 | ||
allow_failures: | ||
- php: '7.4' | ||
- php: '7.3' | ||
- php: '7.2' | ||
- php: hhvm | ||
|
||
env: | ||
- ENABLE_REDIS_EXT=0 | ||
- ENABLE_REDIS_EXT=1 | ||
before_script: | ||
|
||
matrix: | ||
allow_failures: | ||
- php: '7.4' | ||
- php: '5.6' | ||
|
||
install: | ||
- echo 'error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
- sh -c "if [ $ENABLE_REDIS_EXT -eq 1 ]; then echo \"extension=redis.so\" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi" | ||
- composer install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
// Find and initialize Composer | ||
$files = array( | ||
__DIR__ . '/../../vendor/autoload.php', | ||
__DIR__ . '/../../../autoload.php', | ||
__DIR__ . '/../../../../autoload.php', | ||
__DIR__ . '/../vendor/autoload.php', | ||
); | ||
|
||
$found = false; | ||
foreach ($files as $file) { | ||
if (file_exists($file)) { | ||
require_once $file; | ||
break; | ||
} | ||
} | ||
|
||
if (!class_exists('Composer\Autoload\ClassLoader', false)) { | ||
die( | ||
'You need to set up the project dependencies using the following commands:' . PHP_EOL . | ||
'curl -s http://getcomposer.org/installer | php' . PHP_EOL . | ||
'php composer.phar install' . PHP_EOL | ||
); | ||
} | ||
|
||
$REDIS_BACKEND = getenv('REDIS_BACKEND'); | ||
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB'); | ||
if(!empty($REDIS_BACKEND)) { | ||
if (empty($REDIS_BACKEND_DB)) | ||
Resque::setBackend($REDIS_BACKEND); | ||
else | ||
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB); | ||
} | ||
|
||
// Set log level for resque-scheduler | ||
$logLevel = 0; | ||
$LOGGING = getenv('LOGGING'); | ||
$VERBOSE = getenv('VERBOSE'); | ||
$VVERBOSE = getenv('VVERBOSE'); | ||
if(!empty($LOGGING) || !empty($VERBOSE)) { | ||
$logLevel = ResqueScheduler_Worker::LOG_NORMAL; | ||
} | ||
else if(!empty($VVERBOSE)) { | ||
$logLevel = ResqueScheduler_Worker::LOG_VERBOSE; | ||
} | ||
|
||
// Check for jobs every $interval seconds | ||
$interval = 5; | ||
$INTERVAL = getenv('INTERVAL'); | ||
if(!empty($INTERVAL)) { | ||
$interval = $INTERVAL; | ||
} | ||
|
||
// Load the user's application if one exists | ||
$APP_INCLUDE = getenv('APP_INCLUDE'); | ||
if($APP_INCLUDE) { | ||
if(!file_exists($APP_INCLUDE)) { | ||
die('APP_INCLUDE ('.$APP_INCLUDE.") does not exist.\n"); | ||
} | ||
|
||
require_once $APP_INCLUDE; | ||
} | ||
|
||
$PREFIX = getenv('PREFIX'); | ||
if(!empty($PREFIX)) { | ||
fwrite(STDOUT, '*** Prefix set to '.$PREFIX."\n"); | ||
Resque_Redis::prefix($PREFIX); | ||
} | ||
|
||
$worker = new ResqueScheduler_Worker(); | ||
$worker->logLevel = $logLevel; | ||
|
||
$PIDFILE = getenv('PIDFILE'); | ||
if ($PIDFILE) { | ||
file_put_contents($PIDFILE, getmypid()) or | ||
die('Could not write PID information to ' . $PIDFILE); | ||
} | ||
|
||
fwrite(STDOUT, "*** Starting scheduler worker\n"); | ||
$worker->work($interval); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Replace these with your own: | ||
# [PATH/TO/RESQUE] | ||
# [PATH/TO/RESQUE-SCHEDULER] | ||
# [UID] | ||
# [GID] | ||
# [APP_INCLUDE] | ||
|
||
check process resque-scheduler_worker | ||
with pidfile /var/run/resque/scheduler-worker.pid | ||
start program = "/bin/sh -c 'APP_INCLUDE=[APP_INCLUDE] RESQUE_PHP=[PATH/TO/RESQUE] PIDFILE=/var/run/resque/scheduler-worker.pid nohup php -f [PATH/TO/RESQUE-SCHEDULER]/resque-scheduler.php > /var/log/resque/scheduler-worker.log &'" as uid [UID] and gid [GID] | ||
stop program = "/bin/sh -c 'kill -s QUIT `cat /var/run/resque/scheduler-worker.pid` && rm -f /var/run/resque/scheduler-worker.pid; exit 0;'" | ||
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory? | ||
group resque-scheduler_workers |
Oops, something went wrong.