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

LiteSpeedProxy::stop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
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
    protected $cacheDir = 'cachedata';
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function start()
28
    {
29
        /*$process = $this->runCommand([
30
            $this->getBinary(),
31
            'status',
32
        ], true);
33
34
        // Already running
35
        if ('terminated' !== $process->getStatus()) {
36
            return;
37
        }*/
38
39
        $this->runCommand([
40
            $this->getBinary(),
41
            'start',
42
        ], true);
43
44
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function stop()
51
    {
52
        /*$process = $this->runCommand([
53
            $this->getBinary(),
54
            'status',
55
        ], true);
56
57
        // Already stopped
58
        if ('terminated' === $process->getStatus()) {
59
            return;
60
        }*/
61
62
        $this->runCommand([
63
            $this->getBinary(),
64
            'stop',
65
        ], true);
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function clear()
72
    {
73
        $this->runCommand([
74
            'rm',
75
            '-rf',
76
            $this->getCacheDir(),
77
        ], true);
78
79
        $this->runCommand([
80
            'mkdir',
81
            $this->getCacheDir(),
82
        ], true);
83
84
       // $this->start();
85
    }
86
87
    /**
88
     * @param string $cacheDir
89
     */
90
    public function setCacheDir($cacheDir)
91
    {
92
        $this->cacheDir = $cacheDir;
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getCacheDir()
99
    {
100
        return $this->cacheDir;
101
    }
102
}
103