|
1
|
|
|
<?php ///** @noinspection PhpUnusedLocalVariableInspection */ |
|
2
|
|
|
// |
|
3
|
|
|
///** |
|
4
|
|
|
// * This file is part of dispositif/wikibot application |
|
5
|
|
|
// * 2019 : Philippe M. <[email protected]> |
|
6
|
|
|
// * For the full copyright and MIT license information, please view the LICENSE file. |
|
7
|
|
|
// */ |
|
8
|
|
|
// |
|
9
|
|
|
//declare(strict_types=1); |
|
10
|
|
|
// |
|
11
|
|
|
//namespace App\Application; |
|
12
|
|
|
// |
|
13
|
|
|
//use Symfony\Component\Console\Command\Command; |
|
14
|
|
|
//use Symfony\Component\Console\Command\LockableTrait; |
|
15
|
|
|
//use Symfony\Component\Console\Input\InputArgument; |
|
16
|
|
|
//use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
//use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
//use Symfony\Component\Console\Style\SymfonyStyle; |
|
19
|
|
|
// |
|
20
|
|
|
//class WorkerCommand extends Command |
|
21
|
|
|
//{ |
|
22
|
|
|
// use LockableTrait; |
|
23
|
|
|
// |
|
24
|
|
|
// protected static $defaultName = 'bot:worker'; |
|
25
|
|
|
// |
|
26
|
|
|
// protected function configure() |
|
27
|
|
|
// { |
|
28
|
|
|
// $this->setDescription('run a worker')->setHelp( |
|
29
|
|
|
// 'launch a worker script' |
|
30
|
|
|
// ); |
|
31
|
|
|
// $this->addArgument('workerName', InputArgument::OPTIONAL, 'worker name'); |
|
32
|
|
|
// } |
|
33
|
|
|
// |
|
34
|
|
|
// /** |
|
35
|
|
|
// * @param InputInterface $input |
|
36
|
|
|
// * @param OutputInterface $output |
|
37
|
|
|
// * |
|
38
|
|
|
// * @return int|void|null |
|
39
|
|
|
// */ |
|
40
|
|
|
// protected function execute(InputInterface $input, OutputInterface $output) |
|
41
|
|
|
// { |
|
42
|
|
|
// // Prevent multiple executions of the same command in a single server |
|
43
|
|
|
// // todo: install symfony/lock or implement naive SQL lock |
|
44
|
|
|
// // if (!$this->lock()) { |
|
45
|
|
|
// // $output->writeln('The command is already running in another process.'); |
|
46
|
|
|
// // return 0; |
|
47
|
|
|
// // } |
|
48
|
|
|
// |
|
49
|
|
|
// // $helper = $this->getHelper('question'); |
|
50
|
|
|
// // $question = new Question('Please select a limit for this execution: ', 25); |
|
51
|
|
|
// // $limit = $helper->ask($input, $output, $question); |
|
52
|
|
|
// |
|
53
|
|
|
// $workerName = $input->getArgument('workerName'); |
|
54
|
|
|
// $io = new SymfonyStyle($input, $output); |
|
55
|
|
|
// |
|
56
|
|
|
// if (!$workerName) { |
|
57
|
|
|
// $workerName = $io->ask('Quel worker ?'); |
|
58
|
|
|
// $workerName = strtolower($workerName); |
|
59
|
|
|
// } |
|
60
|
|
|
// |
|
61
|
|
|
// $bot = new WikiBotConfig(); |
|
62
|
|
|
// |
|
63
|
|
|
//// if ('wstat' === $workerName) { |
|
64
|
|
|
//// $worker = new WstatWorker(); |
|
65
|
|
|
//// $worker->run(); |
|
66
|
|
|
//// } |
|
67
|
|
|
// if ('fileworker' === $workerName) { |
|
68
|
|
|
// $worker = new FileWorker(); // todo inject $io dans construct() ? |
|
69
|
|
|
// $worker->run($io); |
|
70
|
|
|
// } |
|
71
|
|
|
// |
|
72
|
|
|
// echo "Pas de $workerName ici !\n"; |
|
73
|
|
|
// exit('EXIT'); |
|
74
|
|
|
// } |
|
75
|
|
|
//} |
|
76
|
|
|
|