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

LiteSpeedProxy::clear()   A

Complexity

Conditions 1
Paths 1

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 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
use Symfony\Component\Process\Process;
16
17
class LiteSpeedProxy extends AbstractProxy
18
{
19
    protected $binary = '/usr/local/lsws/bin/lswsctrl';
20
21
    protected $port = 8080;
22
23
    protected $cacheDir = 'cachedata';
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function start()
29
    {
30
        try {
31
            $process = $this->runCommand([
32
                $this->getBinary(),
33
                'status',
34
            ], true);
35
36
            var_dump('Output:' . $process->getOutput());
0 ignored issues
show
Security Debugging Code introduced by
var_dump('Output:' . $process->getOutput()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
37
        } catch (ProcessFailedException $e) {
38
            var_dump('Exception: ' . $e->getMessage());
39
        }
40
41
        try {
42
            $this->runCommand([
43
                $this->getBinary(),
44
                'start',
45
            ], true);
46
        } catch (ProcessFailedException $e) {
47
            var_dump($e->getMessage());
48
        }
49
50
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function stop()
57
    {
58
        /*$this->runCommand([
59
            $this->getBinary(),
60
            'stop',
61
        ], true);*/
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function clear()
68
    {
69
        $this->runCommand([
70
            'rm',
71
            '-rf',
72
            $this->getCacheDir(),
73
        ], true);
74
75
        $this->runCommand([
76
            'mkdir',
77
            $this->getCacheDir(),
78
        ], true);
79
80
        $this->start();
81
    }
82
83
    /**
84
     * @param string $cacheDir
85
     */
86
    public function setCacheDir($cacheDir)
87
    {
88
        $this->cacheDir = $cacheDir;
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function getCacheDir()
95
    {
96
        return $this->cacheDir;
97
    }
98
}
99