Completed
Pull Request — master (#444)
by Yanick
02:46
created

LiteSpeedProxy::setCacheDir()   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 1
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
        $process = $this->runCommand([
30
            $this->getBinary(),
31
            'status',
32
        ], true);
33
34
        // Already running
35
        if (false !== strpos($process->getOutput(), 'litespeed is running with PID')) {
36
            return;
37
        }
38
39
        // Starting deamonized
40
        $this->runCommand([
41
            $this->getBinary(),
42
            'start',
43
        ], true);
44
45
        $this->waitFor($this->getIp(), $this->getPort(), 2000);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function stop()
52
    {
53
        $this->runCommand([
54
            $this->getBinary(),
55
            'stop',
56
        ], true);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function clear()
63
    {
64
        $iterator = new DirectoryIterator($this->getCacheDir());
65
        var_dump(posix_getpwuid($iterator->getOwner()));
0 ignored issues
show
Security Debugging Code introduced by
var_dump(posix_getpwuid($iterator->getOwner())); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
66
67
        $this->runCommand([
68
            'rm',
69
            '-rf',
70
            $this->getCacheDir(),
71
        ], true);
72
73
        $this->runCommand([
74
            'mkdir',
75
            '-p',
76
            $this->getCacheDir(),
77
        ]);
78
79
        $iterator = new DirectoryIterator($this->getCacheDir());
80
        var_dump(posix_getpwuid($iterator->getOwner()));
81
82
        $this->start();
83
    }
84
85
    /**
86
     * @param string $cacheDir
87
     */
88
    public function setCacheDir($cacheDir)
89
    {
90
        $this->cacheDir = $cacheDir;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getCacheDir()
97
    {
98
        return $this->cacheDir;
99
    }
100
}
101