Completed
Pull Request — master (#444)
by Yanick
03:18
created

LiteSpeedProxy::clear()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
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
            'start',
30
        ], true);
31
32
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function stop()
39
    {
40
        $this->runCommand([
41
            $this->getBinary(),
42
            'stop',
43
        ], true);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function clear()
50
    {
51
        try {
52
            $this->runCommand([
53
                $this->getBinary(),
54
                'status',
55
            ], true);
56
57
            $this->stop();
58
        } catch (ProcessFailedException $e) {
59
            // Not running, no need to stop
60
        }
61
62
        $this->start();
63
    }
64
}
65