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

LiteSpeedProxy::getCacheDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
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/openlitespeed';
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
            '-d',
43
        ], true);
44
45
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function stop()
52
    {
53
        /*$process = $this->runCommand([
54
            $this->getBinary(),
55
            'status',
56
        ], true);
57
58
        // Already stopped
59
        if ('terminated' === $process->getStatus()) {
60
            return;
61
        }*/
62
63
        $this->runCommand([
64
            $this->getBinary(),
65
            'stop',
66
        ], true);
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function clear()
73
    {
74
        $this->runCommand([
75
            'rm',
76
            '-rf',
77
            $this->getCacheDir(),
78
        ], true);
79
80
        $this->runCommand([
81
            'mkdir',
82
            $this->getCacheDir(),
83
        ], true);
84
85
        $this->start();
86
    }
87
88
    /**
89
     * @param string $cacheDir
90
     */
91
    public function setCacheDir($cacheDir)
92
    {
93
        $this->cacheDir = $cacheDir;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getCacheDir()
100
    {
101
        return $this->cacheDir;
102
    }
103
}
104