-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Option to control task execution per node #309
Comments
@chrosey Can you give me a usecase for this? |
Database migration, upgrade wizards,... |
I may have an addition: |
@chrosey currently this is not possible. Everything is bound to an Application but you can of course write you own Tasks and since you get the node as parameter, you can do everything you want. |
@simonschaufi Sorry, but this is not true. @chrosey You can add options to a node which are merged with other options: Surf/src/Domain/Service/TaskManager.php Line 91 in 6f532c8
Then you must not configure the same option at the deployment, globalTaskOptions ( Maybe we should write the order with examples to the documentation. |
Ok. I was really not aware of this. But is it true that you cannot bind a task only to a defined Node meaning all tasks will run on all nodes. |
@t3easy I tried that with opcache-reset. foreach ($targets1 as $t) {
$node = new Node($t);
$node->setHostname($t);
$node->setOption('username', $deploymentUser);
$node->setOption(
\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class,
[
'scriptIdentifier' => 'erase-all-humans',
'baseUrl' => 'https://'.$node->getHostname(),
'stream_context' => [
'http' => [
'header' => 'Host: example.com',
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
],
]
);
$application->addNode($node);
} but there is an Error while deploying. Node1 (CraftCMS) TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
Got exception "The required option "scriptIdentifier" is missing." rolling back.
Rolling back TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
In Task.php line 79:
[TYPO3\Surf\Exception\InvalidConfigurationException]
The required option "scriptIdentifier" is missing.
Exception trace:
at /tmp/vendor/typo3/surf/src/Domain/Model/Task.php:79
TYPO3\Surf\Domain\Model\Task->configureOptions() at /tmp/vendor/typo3/surf/src/Domain/Model/Task.php:48
TYPO3\Surf\Domain\Model\Task->rollback() at /tmp/vendor/typo3/surf/src/Domain/Service/TaskManager.php:72
TYPO3\Surf\Domain\Service\TaskManager->rollback() at /tmp/vendor/typo3/surf/src/Domain/Model/SimpleWorkflow.php:107
TYPO3\Surf\Domain\Model\SimpleWorkflow->run() at /tmp/vendor/typo3/surf/src/Domain/Model/Deployment.php:184
TYPO3\Surf\Domain\Model\Deployment->deploy() at /tmp/vendor/typo3/surf/src/Command/DeployCommand.php:66
TYPO3\Surf\Command\DeployCommand->execute() at /tmp/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /tmp/vendor/symfony/console/Application.php:1012
Symfony\Component\Console\Application->doRunCommand() at /tmp/vendor/typo3/surf/src/Cli/Symfony/ConsoleApplication.php:64
TYPO3\Surf\Cli\Symfony\ConsoleApplication->doRunCommand() at /tmp/vendor/symfony/console/Application.php:272
Symfony\Component\Console\Application->doRun() at /tmp/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /tmp/vendor/typo3/surf/src/Cli/Symfony/ConsoleApplication.php:49
TYPO3\Surf\Cli\Symfony\ConsoleApplication->run() at /tmp/vendor/typo3/surf/surf:14 How should the Syntax to set these options be to let it work? |
@simonschaufi thats why I would suggest maybe an boolean meta-option for |
@chrosey You set the option wrong. $node->setOption(
\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class . '[scriptIdentifier]',
'erase-all-humans'
); |
The option key for a global task option is always |
@t3easy: worked like a charm. Did I miss this in the documentation? |
No, I guess there is no dokumentation how options can be set and how they are merged/overridden to the final result. |
Expected Behavior
Add an option to control whether a task is executed on a node.
Actual Behavior
Unless defined, every Task is run on every node the Application ist hosted on. This is not necessary for Tasks that need to run once only.
The text was updated successfully, but these errors were encountered: