Skip to content

New development from our side #25

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

Open
wants to merge 152 commits into
base: 1.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
45d7ae0
added generated repos
Nov 15, 2015
2e7c2f3
regenerated entities because i don't always think what i'm doing
Nov 17, 2015
f4021a1
added getter and setter methods, renamed relation field in command yml
Nov 17, 2015
b9c1de5
problem with constraints seems to be myisam, still search for solution
Nov 17, 2015
18e3959
finally got entities with correct relations working
Nov 21, 2015
e9b4aa2
refactoring in listcontroller (removed duplicate code, added action f…
Nov 21, 2015
e92c314
started list of execution rights
Nov 21, 2015
75f051e
added list of executions requirements incl. translations, split routi…
Nov 22, 2015
a7c80b0
still refactoring, detail-view not working right now
Nov 26, 2015
6998a65
added missing twig
Nov 26, 2015
13a3338
everything's working again as before, there's still a lot of work to …
Nov 27, 2015
5858fc5
added flag to enable/disable logging of executions
Nov 27, 2015
5528b89
logging can now be toggled from list
Nov 29, 2015
6cc417a
added Testcommand
Dec 1, 2015
dfa5435
moved testcommand to another namespace
Dec 1, 2015
88f58cc
exexcution logging to database works
Dec 2, 2015
71606d4
added list of previous executions for a given command, started changi…
Dec 3, 2015
94657c0
translations (en) converted json, minor frontend changes
Dec 4, 2015
49d3008
added bower to keep track of js-libraries, changed french translation…
Dec 6, 2015
b1a09f3
remove Resources which are now managed by composer
Dec 6, 2015
0d83b61
started cronhelper
Dec 6, 2015
c4938a0
changed from glyphicons to fontawesome because of selection of icons,…
Dec 8, 2015
1614d7b
added input field for expected runtime
Dec 8, 2015
fb1b8fc
started execution graphs
Dec 10, 2015
362a997
graphs for execution log working (in principle), trendline in progress
Dec 12, 2015
d3c42b5
runtime graph working with moving average
Dec 12, 2015
b1866ba
added translations, fixed some changed translation keys
Dec 12, 2015
27c2d93
input form for user/rights requirements shown correctly
Dec 12, 2015
6ee79c3
adding, changing and removing rights works, next step: relation from …
Dec 12, 2015
c5fc8b8
managing rights works, adding rights to commands works, editing comma…
Dec 13, 2015
3e2da41
finally got rid of lazy loading, but there is still a problem showing…
Dec 14, 2015
1aacce1
editing commands with requirements works, added some doc and translat…
Dec 16, 2015
41f4fc0
renamed RightController to get a more consistent naming, added option…
Dec 16, 2015
de4dc07
fixed logging to database, started logrotate command
Dec 16, 2015
3d30a33
logrotate with number as limit working
Dec 16, 2015
67eecc1
added expected runtime to runtimegraph
Dec 16, 2015
2038702
a little refactoring of commands, cleanup command working
Dec 16, 2015
1da8d19
refactoring, list of executions
Dec 17, 2015
f13d247
refactoring, added vendor to git, added list of all executions
Dec 17, 2015
bb0420c
execution list can be filtered and ordered. found out new version doe…
Dec 17, 2015
84986b7
extended .travis.yml, changed 'patter' to 'path' in routing.yml
Dec 21, 2015
fcfe318
working on tests
Dec 26, 2015
fef2492
fixed bug after renaming route
Dec 27, 2015
85dae71
startet extending tests to get travis running
Dec 27, 2015
4defef9
startet extending tests to get travis running
Dec 27, 2015
9c78340
fixed all 2.8 deprecation notices for initNewCommand test
Dec 27, 2015
d3ab72f
finally got phpunits with fixtures working. please NEVER EVER execute…
Dec 30, 2015
27a331a
CommandControllerTest working and green :-)
Dec 30, 2015
2f898fa
Update layout.html.twig
homerjsimpson000 Dec 31, 2015
f099779
Update right.html.twig
homerjsimpson000 Dec 31, 2015
dff2aa2
Update indexCommands.html.twig
homerjsimpson000 Dec 31, 2015
0702990
Update global.css
homerjsimpson000 Dec 31, 2015
cc11dd2
Update global.js
homerjsimpson000 Dec 31, 2015
451c8e2
a little JS refactoring, translations
Jan 6, 2016
c3f457f
finished CommandControllerTest
Jan 6, 2016
f53dfa9
Update ListControllerTest.php
homerjsimpson000 Jan 7, 2016
71d5164
Update ExecuteCommandTest.php
homerjsimpson000 Jan 7, 2016
512ea39
finished first command test, started fistures for userhost tests
Jan 8, 2016
4005be2
HelloCommandTest working again
Jan 9, 2016
35a3da9
fixed CommandSchedulerBaseTest to work with commands
Jan 9, 2016
cf62afa
tests for scheduler:execute working again
Jan 10, 2016
aa47b3f
Update README.md
homerjsimpson000 Jan 11, 2016
0344c41
Update README.md
homerjsimpson000 Jan 11, 2016
19a8860
removed superuser field from database and entities, simplified loadin…
Jan 11, 2016
63a780d
temporary commit, work on tests in progress
Jan 11, 2016
188b6f9
Merge branch 'master' of github.com:homerjsimpson000/CommandScheduler…
Jan 11, 2016
4645d50
Update ListControllerTest.php
homerjsimpson000 Jan 12, 2016
698eaf1
Update LogRotateCommandTest.php
homerjsimpson000 Jan 12, 2016
d4b699f
Update MonitorCommandTest.php
homerjsimpson000 Jan 12, 2016
704174e
Update ListControllerTest.php
homerjsimpson000 Jan 12, 2016
e699184
Update CommandSchedulerBaseTest.php
homerjsimpson000 Jan 12, 2016
0201157
Update services.yml
homerjsimpson000 Jan 12, 2016
2d8107c
Update .travis.yml
homerjsimpson000 Jan 12, 2016
56d3d90
fixed selector to make get test running
Jan 12, 2016
79e5d50
completed fixtures, listcontrollertest working
Jan 12, 2016
3ba9291
quoted scalars in yaml, added symfony/asset to composer.json. hopeful…
Jan 12, 2016
dd1763d
all tests green (dance)
Jan 13, 2016
890ac98
removed symfony/asset from composer.json (didn't work as expected) an…
Jan 13, 2016
5a7a5f9
finished MonitorCommandControllerTest, green
Jan 13, 2016
c8658b9
replaced numeric values for tests with constants
Jan 13, 2016
b60da58
removed symfony 2.3 from travis - it's still supported by sensiolab, …
Jan 13, 2016
aa31a5a
removed unsupported symfony versions from composer.json and travis.yml
Jan 13, 2016
2935e30
fixed problem with fixtures
Jan 13, 2016
31a8049
some refactoring for monitoring
Jan 13, 2016
67a744c
added monitoring view
Jan 13, 2016
6914e25
added monitoring view
Jan 13, 2016
a6ae6d8
executecommandTest working, TODO: check user/rights requirements
Jan 13, 2016
64bf90e
Update config_test.yml
homerjsimpson000 Jan 14, 2016
5ac266d
Update LogRotateCommand.php
homerjsimpson000 Jan 14, 2016
aa6b867
Update MonitorCommand.php
homerjsimpson000 Jan 14, 2016
ea733ea
Update ExecuteCommand.php
homerjsimpson000 Jan 14, 2016
87318b8
Update HelloCommand.php
homerjsimpson000 Jan 14, 2016
d051d59
Merge branch 'master' of github.com:homerjsimpson000/CommandScheduler…
Jan 14, 2016
bce87ce
(hopefully last) change to fixtures, added 'useless' option to HelloC…
Jan 14, 2016
9d4d27e
added data-attribute (dbid) to all rows
Jan 14, 2016
63ea544
finished ExecuteCommandTest
Jan 14, 2016
6ca4902
added 'Empty' tests to ListControllerTest
Jan 14, 2016
40c8df0
finished ExecutionControllerTest
Jan 14, 2016
1bb0966
Test Suite complete and green
Jan 15, 2016
03a2daf
merge from j-mose 1.1. I want to keep php 5.3 compatibility, so i did…
Jan 16, 2016
2b2024c
finished merge/changes for ExecuteCommand
Jan 16, 2016
4c0788e
refactoring of monitoring completed with pull from original
Jan 16, 2016
a1036ef
fixed wrong link in menu
Jan 16, 2016
0906294
Update README.md
homerjsimpson000 Jan 18, 2016
898349c
Update .travis.yml
homerjsimpson000 Jan 18, 2016
b78a7bb
logrotate command working with refactored queries
Jan 31, 2016
930d153
monitor command test working and green
Jan 31, 2016
381c965
found/fixed error while testing, test green...
Jan 31, 2016
1c1f845
Update README.md
homerjsimpson000 Jan 31, 2016
628e81a
Update BaseController.php
homerjsimpson000 Feb 1, 2016
a4f5110
Update ScheduledCommandType.php
homerjsimpson000 Feb 1, 2016
1ed0112
Update BaseController.php
homerjsimpson000 Feb 1, 2016
faa55f4
Update RightsParser.php
homerjsimpson000 Feb 1, 2016
3529006
Update UserHostRepository.php
homerjsimpson000 Feb 1, 2016
7fa96d0
Update LogRotateCommand.php
homerjsimpson000 Feb 1, 2016
15c3fde
Update LogRotateCommand.php
homerjsimpson000 Feb 1, 2016
fee0e25
Update RightsParser.php
homerjsimpson000 Feb 1, 2016
c65327b
Update HelloCommand.php
homerjsimpson000 Feb 1, 2016
3f10dc0
Update MonitorCommand.php
homerjsimpson000 Feb 1, 2016
fb48866
Update UserHostChoiceType.php
homerjsimpson000 Feb 1, 2016
df37039
Update MonitorService.php
homerjsimpson000 Feb 1, 2016
7a25dc4
Update ExecutionRepository.php
homerjsimpson000 Feb 1, 2016
26270f5
Update MonitorService.php
homerjsimpson000 Feb 1, 2016
aabba59
Update LogRotateCommand.php
homerjsimpson000 Feb 1, 2016
bbefa5e
fixed rightsparser
Feb 1, 2016
958faab
Merge pull request #2 from homerjsimpson000/structural_changes
homerjsimpson000 Feb 2, 2016
14292fc
still working on sensiolab report
Feb 2, 2016
01af9da
no more interactive confirmation because breaks tests
Feb 2, 2016
a6c988c
organize imports, remove unused use statements
Feb 2, 2016
b53d5c6
removed unused method
Feb 2, 2016
0fcbb80
Update README.md
homerjsimpson000 Feb 2, 2016
5368bed
output saved to database even if no logfile is specified
Feb 3, 2016
f1fa5a1
Create .sensiolabs.yml
homerjsimpson000 Feb 4, 2016
b8d7a8c
Update .sensiolabs.yml
homerjsimpson000 Feb 4, 2016
e5d49f2
Update .sensiolabs.yml
homerjsimpson000 Feb 4, 2016
62e5fea
showing output in modal works, but translation still doesn't
Feb 4, 2016
9a77afb
Merge branch 'master' of github.com:homerjsimpson000/CommandScheduler…
Feb 4, 2016
af6b8f4
finished ajax output for executions
Feb 7, 2016
0b32b93
fixed touchpad typo - arrgl
Feb 7, 2016
187c8fd
update versioninfo in README
Feb 7, 2016
e08e917
Merge pull request #2 from homerjsimpson000/master
tis-dm-webfactory Feb 8, 2016
dcf0955
Update commandExecutions.html.twig
tis-dm-webfactory Feb 8, 2016
9fd08e2
Update ScheduledCommand.php
tis-dm-webfactory Feb 18, 2016
436f66a
Update ScheduledCommand.php
tis-dm-webfactory Feb 19, 2016
afbe012
Update routing.yml
tis-dm-webfactory Feb 23, 2016
d95dc55
Update table.js
tis-dm-webfactory Feb 23, 2016
d9edaef
Update ListController.php
tis-dm-webfactory May 31, 2016
b18798f
Update ScheduledCommandRepository.php
tis-dm-webfactory Jun 3, 2016
f45982b
Update ScheduledCommand.orm.yml
tis-dm-webfactory Jun 3, 2016
3c8b469
fixed conflicts
Apr 12, 2017
fbf78c1
Update ExecuteCommand.php
tis-dm-webfactory Apr 12, 2017
175750f
Update README.md
tis-dm-webfactory Nov 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory":"Resources/public/vendor"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.sql
vendor/
5 changes: 5 additions & 0 deletions .sensiolabs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rules:
symfony.controller.non_action_public_method_in_controller_class:
enabled: false
symfony.dependency_injection.no_container_as_parameter:
enabled: false
21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
Expand All @@ -16,14 +15,18 @@ branches:

matrix:
include:
- php: 5.3
env: SYMFONY_VERSION='2.8.*'
- php: 5.5
env: SYMFONY_VERSION=2.3.*
- php: 5.5
env: SYMFONY_VERSION=2.4.*
- php: 5.5
env: SYMFONY_VERSION=2.6.*
- php: 5.5
env: SYMFONY_VERSION=2.7.*
env: SYMFONY_VERSION='2.8.*'
- php: 5.6
env: SYMFONY_VERSION='2.8.*'
- php: 5.6
env: SYMFONY_VERSION='3.0'
- php: 7.0
env: SYMFONY_VERSION='2.8.*'
- php: 7.0
env: SYMFONY_VERSION='3.0'
allow_failures:
- php: nightly

Expand All @@ -42,4 +45,4 @@ after_success: |
sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" -a "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then php vendor/bin/coveralls -v --config .coveralls.yml; fi;'

notifications:
email: julienguyon@hotmail.com
email: homerj.simpson000@gmail.com
148 changes: 71 additions & 77 deletions Command/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,24 @@
namespace JMose\CommandSchedulerBundle\Command;

use Cron\CronExpression;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use JMose\CommandSchedulerBundle\Entity\Execution;
use JMose\CommandSchedulerBundle\Entity\ScheduledCommand;
use JMose\CommandSchedulerBundle\Component\CommandOutput;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use JMose\CommandSchedulerBundle\Entity\ScheduledCommand;

/**
* Class ExecuteCommand : This class is the entry point to execute all scheduled command
*
* @author Julien Guyon <[email protected]>
* @package JMose\CommandSchedulerBundle\Command
*/
class ExecuteCommand extends ContainerAwareCommand
class ExecuteCommand extends SchedulerBaseCommand
{

/**
* @var \Doctrine\ORM\EntityManager
*/
private $em;

/**
* @var string
*/
private $logPath;

/**
* @var boolean
*/
private $dumpMode;

/**
* @var integer
*/
private $commandsVerbosity;

/**
* @inheritdoc
*/
Expand All @@ -55,66 +35,47 @@ protected function configure()
}

/**
* Initialize parameters and services used in execute function
*
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->dumpMode = $input->getOption('dump');
$this->logPath = $this->getContainer()->getParameter('jmose_command_scheduler.log_path');

// If logpath is not set to false, append the directory separator to it
if(false !== $this->logPath) {
$this->logPath = rtrim($this->logPath, '/\\') . DIRECTORY_SEPARATOR ;
}

// Store the original verbosity before apply the quiet parameter
$this->commandsVerbosity = $output->getVerbosity();

if( true === $input->getOption('no-output')){
$output->setVerbosity( OutputInterface::VERBOSITY_QUIET );
}

$this->em = $this->getContainer()->get('doctrine')->getManager(
$this->getContainer()->getParameter('jmose_command_scheduler.doctrine_manager')
);
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>Start : ' . ($this->dumpMode ? 'Dump' : 'Execute') . ' all scheduled command</info>');

// Before continue, we check that the output file is valid and writable (except for gaufrette)
if (false !== $this->logPath && strpos($this->logPath, 'gaufrette:') !== 0 && false === is_writable($this->logPath)) {
if (
false !== $this->logPath &&
strpos($this->logPath, 'gaufrette:') !== 0 &&
false === is_writable($this->logPath)
) {
$output->writeln(
'<error>'.$this->logPath.
' not found or not writable. You should override `log_path` in your config.yml'.'</error>'
'<error>' . $this->logPath .
' not found or not writable. You should override `log_path` in your config.yml' . '</error>'
);

return;
}

$commands = $this->em->getRepository('JMoseCommandSchedulerBundle:ScheduledCommand')->findEnabledCommand();
$commands = $this->getRepository('ScheduledCommand')->findEnabledCommand();

$noneExecution = true;
foreach ($commands as $command) {

/** @var ScheduledCommand $command */
$cron = CronExpression::factory($command->getCronExpression());
// check if the command's rights (user and host) allow execution of the command at all.
if (!$command->checkRights()) {
continue;
}

$cron = CronExpression::factory($command->getCronExpression());
$nextRunDate = $cron->getNextRunDate($command->getLastExecution());
$now = new \DateTime();
$now = new \DateTime();

if ($command->isExecuteImmediately()) {
$noneExecution = false;
$output->writeln(
'Immediately execution asked for : <comment>' . $command->getCommand() . '</comment>'
'Immediately execution asked for : <comment>' . $command->getCommand() . ' ' . $command->getArguments() . '</comment>'
);

if (!$input->getOption('dump')) {
Expand All @@ -123,9 +84,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
} elseif ($nextRunDate < $now) {
$noneExecution = false;
$output->writeln(
'Command <comment>'.$command->getCommand().
'</comment> should be executed - last execution : <comment>'.
$command->getLastExecution()->format('d/m/Y H:i:s').'.</comment>'
'Command <comment>' . $command->getCommand() .
'</comment> should be executed - last execution : <comment>' .
$command->getLastExecution()->format('d/m/Y H:i:s') . '.</comment>'
);

if (!$input->getOption('dump')) {
Expand All @@ -144,10 +105,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
private function executeCommand(ScheduledCommand $scheduledCommand, OutputInterface $output, InputInterface $input)
{
$scheduledCommand = $this->em->merge($scheduledCommand);
$scheduledCommand->setLastExecution(new \DateTime());
$now = new \DateTime();
/** @var ScheduledCommand $scheduledCommand */
$scheduledCommand = $this->entityManager->merge($scheduledCommand);
$scheduledCommand->setLastExecution($now);
$scheduledCommand->setLocked(true);
$this->em->flush();

if ($scheduledCommand->logExecutions()) {
$log = new Execution();
$log->setCommand($scheduledCommand);
$log->setExecutionDate($now);
$this->entityManager->persist($log);
$scheduledCommand->addLog($log);
}

$this->entityManager->flush();

try {
$command = $this->getApplication()->find($scheduledCommand->getCommand());
Expand All @@ -161,47 +133,69 @@ private function executeCommand(ScheduledCommand $scheduledCommand, OutputInterf
$input = new ArrayInput(array_merge(
array(
'command' => $scheduledCommand->getCommand(),
'--env' => $input->getOption('env')
'--env' => $input->getOption('env')
),
$scheduledCommand->getArguments(true)
));

// Use a StreamOutput or NullOutput to redirect write() and writeln() in a log file
if (false === $this->logPath || '' != $scheduledCommand->getLogFile() ) {
$logOutput = new NullOutput();
}else{
$logOutput = new StreamOutput(fopen(
$this->logPath . $scheduledCommand->getLogFile(), 'a', false
),$this->commandsVerbosity );
} else {
$logOutput = new StreamOutput(
fopen(
$this->logPath . $scheduledCommand->getLogFile(),
'a',
false
),
$this->commandsVerbosity
);
}

$commandOutput = new CommandOutput();
$commandOutput->setDefaultOutput($logOutput);

// Execute command and get return code
try {
$output->writeln('<info>Execute</info> : <comment>' . $scheduledCommand->getCommand()
. ' ' .$scheduledCommand->getArguments() . '</comment>');
$result = $command->run($input, $logOutput);
. ' ' . $scheduledCommand->getArguments() . '</comment>');
$result = $command->run($input, $commandOutput);
sleep(3);
} catch (\Exception $e) {
$logOutput->writeln($e->getMessage());
$logOutput->writeln($e->getTraceAsString());
$result = -1;
}

if (false === $this->em->isOpen()) {
if (false === $this->entityManager->isOpen()) {
$output->writeln('<comment>Entity manager closed by the last command.</comment>');
$this->em = $this->em->create($this->em->getConnection(), $this->em->getConfiguration());
$this->entityManager = $this->entityManager->create($this->entityManager->getConnection(), $this->entityManager->getConfiguration());
}

$scheduledCommand = $this->em->merge($scheduledCommand);
$scheduledCommand = $this->entityManager->merge($scheduledCommand);
$scheduledCommand->setLastReturnCode($result);
$scheduledCommand->setLocked(false);
$scheduledCommand->setExecuteImmediately(false);
$this->em->flush();

if ($scheduledCommand->logExecutions()) {
/** @var Execution $log */
$log = $scheduledCommand->getCurrentLog();
$log->setReturnCode($result);
$log->setOutput($commandOutput->getBuffer('string'));

// calculate runtime in seconds
$now = new \DateTime();
$runtime = $now->getTimestamp() - $log->getExecutionDate()->getTimestamp();
$log->setRuntime($runtime);
}

$this->entityManager->flush();

/*
* This clear() is necessary to avoid conflict between commands and to be sure that none entity are managed
* before entering in a new command
*/
$this->em->clear();
$this->entityManager->clear();

unset($command);
gc_collect_cycles();
Expand Down
78 changes: 78 additions & 0 deletions Command/HelloCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace JMose\CommandSchedulerBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class HelloCommand : Say Hello World (can be used for testing purposes
*
* @author Daniel Fischer <[email protected]>
* @package JMose\CommandSchedulerBundle\Command
*/
class HelloCommand extends ContainerAwareCommand
{
/**
* @inheritdoc
*/
protected function configure()
{
$this
->setName('schedulerTest:hello')
->setDescription('Hello world testcommand')
->addOption(
'name',
null,
InputOption::VALUE_OPTIONAL,
'Person who shall be greeted',
'World'
)
->addOption(
'trash',
null,
InputOption::VALUE_OPTIONAL,
'can be set to anything, not used',
false
)
->addOption(
'randReturn',
null,
InputOption::VALUE_OPTIONAL,
'set to enable random return value',
false
)
->addOption(
'randSleep',
null,
InputOption::VALUE_OPTIONAL,
'set to enable random sleep to increase runtime',
false
)
->setHelp('This class is used for testing purposes only');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getOption('name');
$output->writeln('<info>Hello ' . $name . '</info>');

if ($input->getOption('randSleep')) {
sleep(rand(1, 10));
}

$return = 0;
if ($input->getOption('randReturn')) {
$return = rand(0, 5);
}

return $return;
}
}
Loading