1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of RoboSystemService. |
4
|
|
|
* |
5
|
|
|
* @author Polyvaniy Oleksii (alexndlm) <[email protected]> |
6
|
|
|
* @copyright 2016 Polyvaniy Oleksii (alexndlm) <[email protected]> |
7
|
|
|
* @license MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Falc\Robo\Service; |
11
|
|
|
|
12
|
|
|
use Falc\Robo\Service\Factory\CommandBuilderFactoryInterface; |
13
|
|
|
use Robo\Contract\CommandInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Reload systemd manager configuration |
17
|
|
|
* |
18
|
|
|
* ``` php |
19
|
|
|
* // Enabling a service: |
20
|
|
|
* $this->taskServiceDaemonReload() |
21
|
|
|
* ->serviceManager('systemd') |
22
|
|
|
* ->run(); |
23
|
|
|
* |
24
|
|
|
* // Compact form: |
25
|
|
|
* $this->taskServiceDaemonReload('systemd')->run(); |
26
|
|
|
* ``` |
27
|
|
|
*/ |
28
|
|
|
class DaemonReload extends BaseTask implements CommandInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Constructor. |
32
|
|
|
* |
33
|
|
|
* @param string $serviceManager Service manager to use. Optional. |
34
|
|
|
* @param CommandBuilderFactoryInterface $factory CommandBuilder factory. Optional. |
35
|
|
|
*/ |
36
|
6 |
|
public function __construct($serviceManager = null, CommandBuilderFactoryInterface $factory = null) |
37
|
|
|
{ |
38
|
6 |
|
parent::__construct($serviceManager, null, $factory); |
39
|
6 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
* |
44
|
|
|
* @throws \InvalidArgumentException |
45
|
|
|
*/ |
46
|
6 |
|
public function getCommand() |
47
|
|
|
{ |
48
|
6 |
|
if ($this->builder === null) { |
49
|
1 |
|
throw new \InvalidArgumentException('Service manager not defined'); |
50
|
|
|
} |
51
|
|
|
|
52
|
5 |
|
$this->builder->daemonReload(); |
53
|
|
|
|
54
|
5 |
|
if (!$this->verbose) { |
55
|
4 |
|
$this->builder->quiet(); |
56
|
4 |
|
} |
57
|
|
|
|
58
|
5 |
|
return $this->builder->getCommand(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
* |
64
|
|
|
* @throws \InvalidArgumentException |
65
|
|
|
*/ |
66
|
1 |
|
public function run() |
67
|
|
|
{ |
68
|
1 |
|
$command = $this->getCommand(); |
69
|
|
|
|
70
|
1 |
|
$this->printTaskInfo('Reload systemd, scanning for new or changed units...'); |
71
|
1 |
|
return $this->executeCommand($command); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|