Completed
Pull Request — master (#444)
by Yanick
03:35
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 DirectoryIterator;
15
16
class LiteSpeedProxy extends AbstractProxy
17
{
18
    protected $binary = '/usr/local/lsws/bin/lswsctrl';
19
20
    protected $port = 8080;
21
22
    protected $cacheDir = '/usr/local/lsws/cachedata';
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function start()
28
    {
29
        $this->runCommand([
30
            $this->getBinary(),
31
            'condrestart',
32
        ], true);
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
            'stop',
45
        ], true);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function clear()
52
    {
53
        // Runs as sudo to make sure it can be removed
54
        $this->runCommand([
55
            'rm',
56
            '-rf',
57
            $this->getCacheDir(),
58
        ], true);
59
60
        // Does not run as sudo to make sure it's created using the correct user
61
        $this->runCommand([
62
            'mkdir',
63
            '-p',
64
            $this->getCacheDir(),
65
        ]);
66
67
        $this->start();
68
    }
69
70
    /**
71
     * @param string $cacheDir
72
     */
73
    public function setCacheDir($cacheDir)
74
    {
75
        $this->cacheDir = $cacheDir;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getCacheDir()
82
    {
83
        return $this->cacheDir;
84
    }
85
}
86