Completed
Pull Request — master (#444)
by Yanick
13:09
created

LiteSpeedProxy::clear()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 2
nc 3
nop 0
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCache package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCache\Test\Proxy;
13
14
use Symfony\Component\Process\Exception\ProcessFailedException;
15
16
class LiteSpeedProxy extends AbstractProxy
17
{
18
    protected $binary = '/usr/local/lsws/bin/lswsctrl';
19
20
    protected $port = 8080;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function start()
26
    {
27
        $this->runCommand(
28
            $this->getBinary(),
29
            [
30
                'start',
31
            ]
32
        );
33
34
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function stop()
41
    {
42
        $this->runCommand(
43
            $this->getBinary(),
44
            [
45
                'stop',
46
            ]
47
        );
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function clear()
54
    {
55
        try {
56
            $this->runCommand(
57
                $this->getBinary(),
58
                [
59
                    'status',
60
                ]
61
            );
62
63
            $this->stop();
64
65
        } catch (ProcessFailedException $e) {
66
            // Not running, no need to stop
67
        }
68
69
        $this->start();
70
    }
71
}
72