Merge pull request #954 from romainneutron/task-manager

[3.9] Updates to task manager
This commit is contained in:
Nicolas Le Goff
2014-02-17 16:20:05 +01:00
10 changed files with 109 additions and 84 deletions

View File

@@ -9,7 +9,7 @@
"php" : ">=5.4",
"alchemy/oauth2php" : "1.0.0",
"alchemy/phlickr" : "0.2.7",
"alchemy/task-manager" : "~1.0",
"alchemy/task-manager" : "2.0.x-dev@dev",
"cboden/ratchet" : "~0.3",
"dailymotion/sdk" : "~1.5",
"data-uri/data-uri" : "~0.1.0",
@@ -29,7 +29,7 @@
"media-alchemyst/media-alchemyst" : "~0.4, >=0.4.4",
"monolog/monolog" : "~1.3",
"mrclay/minify" : "~2.1.6",
"neutron/process-manager" : "~1.0",
"neutron/process-manager" : "2.0.x-dev@dev",
"neutron/silex-imagine-provider" : "~0.1.0",
"neutron/silex-filesystem-provider": "~1.0",
"neutron/sphinxsearch-api" : "~2.0.6",

138
composer.lock generated
View File

@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "6a801036563ebb5473657cb717881f31",
"hash": "6ff48c308a23b2876dbda7b44f6f1d1a",
"packages": [
{
"name": "alchemy-fr/tcpdf-clone",
@@ -294,21 +294,21 @@
},
{
"name": "alchemy/task-manager",
"version": "1.0.2",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/alchemy-fr/task-manager.git",
"reference": "795b9d9781c01cfd82651f66cf3306f53661540c"
"reference": "cefd59cad3ac9b26243f551e704e7142fca79522"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/task-manager/zipball/795b9d9781c01cfd82651f66cf3306f53661540c",
"reference": "795b9d9781c01cfd82651f66cf3306f53661540c",
"url": "https://api.github.com/repos/alchemy-fr/task-manager/zipball/cefd59cad3ac9b26243f551e704e7142fca79522",
"reference": "cefd59cad3ac9b26243f551e704e7142fca79522",
"shasum": ""
},
"require": {
"ext-zmq": "*",
"neutron/process-manager": "~1.0",
"neutron/process-manager": "2.0.x-dev@dev",
"neutron/signal-handler": "~1.0",
"php": ">=5.3.3",
"symfony/event-dispatcher": "~2.0",
@@ -323,7 +323,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "2.0-dev"
}
},
"autoload": {
@@ -353,7 +353,7 @@
"parallel",
"process"
],
"time": "2014-02-12 11:21:06"
"time": "2014-02-14 12:39:44"
},
{
"name": "cboden/ratchet",
@@ -629,16 +629,16 @@
},
{
"name": "doctrine/collections",
"version": "v1.1",
"version": "v1.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "560f29c39cfcfbcd210e5d549d993a39d898b04b"
"reference": "b99c5c46c87126201899afe88ec490a25eedd6a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/560f29c39cfcfbcd210e5d549d993a39d898b04b",
"reference": "560f29c39cfcfbcd210e5d549d993a39d898b04b",
"url": "https://api.github.com/repos/doctrine/collections/zipball/b99c5c46c87126201899afe88ec490a25eedd6a2",
"reference": "b99c5c46c87126201899afe88ec490a25eedd6a2",
"shasum": ""
},
"require": {
@@ -647,7 +647,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
"dev-master": "1.2.x-dev"
}
},
"autoload": {
@@ -693,7 +693,7 @@
"collections",
"iterator"
],
"time": "2013-03-07 12:15:54"
"time": "2014-02-03 23:07:43"
},
{
"name": "doctrine/common",
@@ -1012,16 +1012,16 @@
},
{
"name": "doctrine/orm",
"version": "v2.4.1",
"version": "v2.4.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/doctrine2.git",
"reference": "84373d05a4198ec380918d535abf83c454c3867f"
"reference": "0363a5548d9263f979f9ca149decb9cfc66419ab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/84373d05a4198ec380918d535abf83c454c3867f",
"reference": "84373d05a4198ec380918d535abf83c454c3867f",
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/0363a5548d9263f979f9ca149decb9cfc66419ab",
"reference": "0363a5548d9263f979f9ca149decb9cfc66419ab",
"shasum": ""
},
"require": {
@@ -1084,7 +1084,7 @@
"database",
"orm"
],
"time": "2013-11-12 12:40:13"
"time": "2014-02-08 16:35:09"
},
{
"name": "elasticsearch/elasticsearch",
@@ -1592,16 +1592,16 @@
},
{
"name": "jms/serializer",
"version": "0.14.0",
"version": "0.15.0",
"source": {
"type": "git",
"url": "https://github.com/schmittjoh/serializer.git",
"reference": "22daa254e54f4b69292bd8679d7a6f3a78dc85d4"
"reference": "4a49caf0a20babcf8040fb1cf84f26faff6e7d85"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/schmittjoh/serializer/zipball/22daa254e54f4b69292bd8679d7a6f3a78dc85d4",
"reference": "22daa254e54f4b69292bd8679d7a6f3a78dc85d4",
"url": "https://api.github.com/repos/schmittjoh/serializer/zipball/4a49caf0a20babcf8040fb1cf84f26faff6e7d85",
"reference": "4a49caf0a20babcf8040fb1cf84f26faff6e7d85",
"shasum": ""
},
"require": {
@@ -1617,7 +1617,7 @@
"jackalope/jackalope-doctrine-dbal": "1.0.*",
"propel/propel1": "~1.7",
"symfony/filesystem": "2.*",
"symfony/form": ">=2.1,<2.2-dev",
"symfony/form": ">=2.1,<=2.4-dev",
"symfony/translation": ">=2.0,<2.2-dev",
"symfony/validator": ">=2.0,<2.2-dev",
"symfony/yaml": "2.*",
@@ -1658,7 +1658,7 @@
"serialization",
"xml"
],
"time": "2013-12-04 16:46:05"
"time": "2014-02-10 11:00:05"
},
{
"name": "jms/translation-bundle",
@@ -2045,11 +2045,11 @@
},
{
"name": "neutron/process-manager",
"version": "1.0.1",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/romainneutron/ProcessManager.git",
"reference": "0f44ac5e5b855b24646d692762f77c988d48f4a4"
"reference": "2b3e2a4aa969ce82627199bcdd81fb2553ab25df"
},
"require": {
"php": ">=5.3.3",
@@ -2060,6 +2060,11 @@
"sami/sami": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-0": {
"Neutron": "src"
@@ -2075,7 +2080,7 @@
"homepage": "http://www.lickmychip.com/"
}
],
"time": "2013-12-03 18:48:00"
"time": "2014-02-13 20:27:33"
},
{
"name": "neutron/recaptcha",
@@ -2800,16 +2805,16 @@
},
{
"name": "pimple/pimple",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Pimple.git",
"reference": "471c7d7c52ad6594e17b8ec33efdd1be592b5d83"
"reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Pimple/zipball/471c7d7c52ad6594e17b8ec33efdd1be592b5d83",
"reference": "471c7d7c52ad6594e17b8ec33efdd1be592b5d83",
"url": "https://api.github.com/repos/fabpot/Pimple/zipball/2019c145fe393923f3441b23f29bbdfaa5c58c4d",
"reference": "2019c145fe393923f3441b23f29bbdfaa5c58c4d",
"shasum": ""
},
"require": {
@@ -2844,7 +2849,7 @@
"container",
"dependency injection"
],
"time": "2013-09-19 04:53:08"
"time": "2013-11-22 08:30:29"
},
{
"name": "psr/log",
@@ -3343,16 +3348,16 @@
},
{
"name": "symfony/symfony",
"version": "v2.4.1",
"version": "v2.4.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/symfony.git",
"reference": "377a5fb23bfdc2fb616610b7b7ab7cc9a50e614d"
"reference": "b70633f92ff71ef490af4c17e7ca3f3bf3d0f304"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/symfony/zipball/377a5fb23bfdc2fb616610b7b7ab7cc9a50e614d",
"reference": "377a5fb23bfdc2fb616610b7b7ab7cc9a50e614d",
"url": "https://api.github.com/repos/symfony/symfony/zipball/b70633f92ff71ef490af4c17e7ca3f3bf3d0f304",
"reference": "b70633f92ff71ef490af4c17e7ca3f3bf3d0f304",
"shasum": ""
},
"require": {
@@ -3454,7 +3459,7 @@
"keywords": [
"framework"
],
"time": "2014-01-05 02:12:11"
"time": "2014-02-12 19:27:03"
},
{
"name": "themattharris/tmhoauth",
@@ -3547,16 +3552,16 @@
},
{
"name": "twig/twig",
"version": "v1.15.0",
"version": "v1.15.1",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Twig.git",
"reference": "85e4ff98000157ff753d934b9f13659a953f5666"
"reference": "1fb5784662f438d7d96a541e305e28b812e2eeed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Twig/zipball/85e4ff98000157ff753d934b9f13659a953f5666",
"reference": "85e4ff98000157ff753d934b9f13659a953f5666",
"url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed",
"reference": "1fb5784662f438d7d96a541e305e28b812e2eeed",
"shasum": ""
},
"require": {
@@ -3588,6 +3593,11 @@
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"role": "Project Founder"
},
{
"name": "Twig Team",
"homepage": "https://github.com/fabpot/Twig/graphs/contributors",
"role": "Contributors"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
@@ -3595,7 +3605,7 @@
"keywords": [
"templating"
],
"time": "2013-12-06 07:47:10"
"time": "2014-02-13 10:19:29"
},
{
"name": "vierbergenlars/php-semver",
@@ -4086,21 +4096,21 @@
},
{
"name": "fabpot/goutte",
"version": "v1.0.3",
"version": "v1.0.5",
"source": {
"type": "git",
"url": "https://github.com/fabpot/Goutte.git",
"reference": "75c9f23c4122caf4ea3e87a42a00b471366e707f"
"reference": "a30e84e28fbaf14909d2d007249c24cd0ecd425e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fabpot/Goutte/zipball/75c9f23c4122caf4ea3e87a42a00b471366e707f",
"reference": "75c9f23c4122caf4ea3e87a42a00b471366e707f",
"url": "https://api.github.com/repos/fabpot/Goutte/zipball/a30e84e28fbaf14909d2d007249c24cd0ecd425e",
"reference": "a30e84e28fbaf14909d2d007249c24cd0ecd425e",
"shasum": ""
},
"require": {
"ext-curl": "*",
"guzzle/http": ">=3.0.5,<3.8-dev",
"guzzle/http": "~3.1",
"php": ">=5.3.0",
"symfony/browser-kit": "~2.1",
"symfony/css-selector": "~2.1",
@@ -4109,8 +4119,8 @@
"symfony/process": "~2.1"
},
"require-dev": {
"guzzle/plugin-history": ">=3.0.5,<3.8-dev",
"guzzle/plugin-mock": ">=3.0.5,<3.8-dev"
"guzzle/plugin-history": "~3.1",
"guzzle/plugin-mock": "~3.1"
},
"type": "application",
"extra": {
@@ -4130,7 +4140,9 @@
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
}
],
"description": "A simple PHP Web Scraper",
@@ -4138,7 +4150,7 @@
"keywords": [
"scraper"
],
"time": "2013-08-16 06:03:22"
"time": "2014-01-31 18:02:50"
},
{
"name": "instaclick/php-webdriver",
@@ -4200,16 +4212,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "1.2.14",
"version": "1.2.15",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "d4b3bc1c4b905cd0b3b356e8608857f26a041c1b"
"reference": "6ba4ed2895d538a039d5d5866edc4ec0424c7852"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d4b3bc1c4b905cd0b3b356e8608857f26a041c1b",
"reference": "d4b3bc1c4b905cd0b3b356e8608857f26a041c1b",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6ba4ed2895d538a039d5d5866edc4ec0424c7852",
"reference": "6ba4ed2895d538a039d5d5866edc4ec0424c7852",
"shasum": ""
},
"require": {
@@ -4257,7 +4269,7 @@
"testing",
"xunit"
],
"time": "2014-01-31 08:51:59"
"time": "2014-02-03 07:44:47"
},
{
"name": "phpunit/php-file-iterator",
@@ -4444,16 +4456,16 @@
},
{
"name": "phpunit/phpunit",
"version": "3.7.30",
"version": "3.7.31",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "2f33258fa5a0c330515b7deba2bc040fa5c3953b"
"reference": "d24e9877331039582497052cc3c4d9f465b88210"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2f33258fa5a0c330515b7deba2bc040fa5c3953b",
"reference": "2f33258fa5a0c330515b7deba2bc040fa5c3953b",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d24e9877331039582497052cc3c4d9f465b88210",
"reference": "d24e9877331039582497052cc3c4d9f465b88210",
"shasum": ""
},
"require": {
@@ -4514,7 +4526,7 @@
"testing",
"xunit"
],
"time": "2014-01-31 08:54:33"
"time": "2014-02-03 07:46:27"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -4571,7 +4583,9 @@
],
"minimum-stability": "stable",
"stability-flags": {
"alchemy/task-manager": 20,
"imagine/imagine": 20,
"neutron/process-manager": 20,
"silex/silex": 20,
"silex/web-profiler": 20,
"doctrine/migrations": 20,

View File

@@ -45,7 +45,7 @@ class TasksServiceProvider implements ServiceProviderInterface
});
$app['task-manager.job-factory'] = $app->share(function (Application $app) {
return new JobFactory($app['dispatcher'],isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['logger'], $app['translator']);
return new JobFactory($app['dispatcher'], isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['monolog'], $app['translator']);
});
$app['task-manager.status'] = $app->share(function (Application $app) {
@@ -65,15 +65,17 @@ class TasksServiceProvider implements ServiceProviderInterface
});
$app['task-manager.available-jobs'] = $app->share(function (Application $app) {
$logger = isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['monolog'];
return [
new FtpJob($app['dispatcher'], $app['logger'], $app['translator']),
new ArchiveJob($app['dispatcher'], $app['logger'], $app['translator']),
new BridgeJob($app['dispatcher'], $app['logger'], $app['translator']),
new FtpPullJob($app['dispatcher'], $app['logger'], $app['translator']),
new PhraseanetIndexerJob($app['dispatcher'], $app['logger'], $app['translator']),
new RecordMoverJob($app['dispatcher'], $app['logger'], $app['translator']),
new SubdefsJob($app['dispatcher'], $app['logger'], $app['translator']),
new WriteMetadataJob($app['dispatcher'], $app['logger'], $app['translator']),
new FtpJob($app['dispatcher'], $logger, $app['translator']),
new ArchiveJob($app['dispatcher'], $logger, $app['translator']),
new BridgeJob($app['dispatcher'], $logger, $app['translator']),
new FtpPullJob($app['dispatcher'], $logger, $app['translator']),
new PhraseanetIndexerJob($app['dispatcher'], $logger, $app['translator']),
new RecordMoverJob($app['dispatcher'], $logger, $app['translator']),
new SubdefsJob($app['dispatcher'], $logger, $app['translator']),
new WriteMetadataJob($app['dispatcher'], $logger, $app['translator']),
];
});
}

View File

@@ -11,8 +11,8 @@
namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\TaskManager\AbstractJob as AbstractTMJob;
use Alchemy\TaskManager\JobDataInterface;
use Alchemy\TaskManager\Job\AbstractJob as AbstractTMJob;
use Alchemy\TaskManager\Job\JobDataInterface;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -53,10 +53,10 @@ abstract class AbstractJob extends AbstractTMJob implements JobInterface
/**
* {@inheritdoc}
*/
final protected function doRun(JobDataInterface $data = null)
final protected function doRun(JobDataInterface $data)
{
if (!$data instanceof JobData) {
throw new InvalidArgumentException('JobData must be passed to a JobInterface::Run command.');
throw new InvalidArgumentException(sprintf('Phraseanet jobs require Phraseanet JobData, got %s.', get_class($data)));
}
$this->setPauseDuration($data->getTask()->getPeriod());

View File

@@ -12,7 +12,7 @@
namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\Application;
use Alchemy\TaskManager\JobDataInterface;
use Alchemy\TaskManager\Job\JobDataInterface;
use Alchemy\Phrasea\Model\Entities\Task;
class JobData implements JobDataInterface
@@ -41,4 +41,9 @@ class JobData implements JobDataInterface
{
return $this->task;
}
public function __toString()
{
return sprintf('Task %d (%s)', $this->task->getId(), $this->task->getName());
}
}

View File

@@ -12,7 +12,7 @@
namespace Alchemy\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\TaskManager\Editor\EditorInterface;
use Alchemy\TaskManager\JobInterface as JobTMInterface;
use Alchemy\TaskManager\Job\JobInterface as JobTMInterface;
interface JobInterface extends JobTMInterface
{

View File

@@ -42,7 +42,7 @@ class TaskList implements TaskListInterface
public function entityToTask(TaskEntity $task)
{
$name = $task->getId() ;
$arguments = [$this->phpExec];
$arguments = ['exec', $this->phpExec];
if ($this->phpConf) {
$arguments[] = '-c';

View File

@@ -15,7 +15,7 @@ class JobDataTest extends \PhraseanetTestCase
->disableOriginalConstructor()
->getMock();
$data = new JobData($app, $task);
$this->assertInstanceOf('Alchemy\TaskManager\JobDataInterface', $data);
$this->assertInstanceOf('Alchemy\TaskManager\Job\JobDataInterface', $data);
$this->assertSame($app, $data->getApplication());
$this->assertSame($task, $data->getTask());
}

View File

@@ -3,7 +3,7 @@
namespace Alchemy\Tests\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\TaskManager\Job\JobInterface;
use Alchemy\TaskManager\JobDataInterface;
use Alchemy\TaskManager\Job\JobDataInterface;
use Alchemy\Phrasea\TaskManager\Job\Factory;
abstract class JobTestCase extends \PhraseanetTestCase
@@ -46,7 +46,7 @@ abstract class JobTestCase extends \PhraseanetTestCase
/**
* @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException
* @expectedExceptionMessage JobData must be passed to a JobInterface::Run command.
* @expectedExceptionMessage Phraseanet jobs require Phraseanet JobData, got Alchemy\Tests\Phrasea\TaskManager\Job\WrongJobDataTest.
*/
public function testRunningTheJobWithWrongValueThrowsAnException()
{
@@ -62,4 +62,8 @@ abstract class JobTestCase extends \PhraseanetTestCase
class WrongJobDataTest implements JobDataInterface
{
public function __toString()
{
return 'wrong data';
}
}

View File

@@ -58,7 +58,7 @@ class TaskListTest extends \PhraseanetTestCase
$list = $this->getTaskList();
$n = 1;
foreach ($list->refresh() as $task) {
$this->assertEquals("'/path/to/php' '-c' '/path/to/php-conf' '-f' '".self::$DI['app']['root.path']."/bin/console' '--' '-q' 'task-manager:task:run' '".$n."' '--listen-signal' '--max-duration' '1800' '--max-memory' '134217728'", $task->createProcess()->getCommandLine());
$this->assertEquals("'exec' '/path/to/php' '-c' '/path/to/php-conf' '-f' '".self::$DI['app']['root.path']."/bin/console' '--' '-q' 'task-manager:task:run' '".$n."' '--listen-signal' '--max-duration' '1800' '--max-memory' '134217728'", $task->createProcess()->getCommandLine());
$n++;
}
$this->assertSame(3, $n);